i need to solve ax=b.
where a is a n×n tridiagonal matrix. b is n×n matix. and x is n×n matrix.
what command in matlab i have to use to get the value of x.
shall i use b/a;
but if i use like this i am getting a wrong value.
what is the correct syntax.
If A X = B
then A-1 A X = A-1 B
where A-1 is the inverse of A
so X = A-1 B
So you have to find the inverse of A - never used matlab so don't know how to do it. But here's a basic routine that will invert the NxN matrix E and return the inverted matrix X.
Code:
DEFINT I-N
FOR I = 1 TO N
FOR J = 1 TO N
F(I, J) = E(I, J)
X(I, J) = 0!
NEXT J
X(I, I) = 1!
NEXT I
FOR J = 1 TO N
FOR I = 1 TO N
IF I <> J THEN
F(J, I) = F(J, I) / F(J, J)
X(J, I) = X(J, I) / F(J, J)
END IF
NEXT I
X(J, J) = X(J, J) / F(J, J)
F(I, I) = 1!
FOR K = 1 TO N
IF K <> J THEN
FOR L = 1 TO N
IF L <> J THEN F(K, L) = F(K, L) - F(K, J) * F(J, L)
X(K, L) = X(K, L) - F(K, J) * X(J, L)
NEXT L
F(K, J) = 0!
END IF
NEXT K
NEXT J