Thread Subject: Tridiagonal matrix - Gaussian elimination, loop

Subject: Tridiagonal matrix - Gaussian elimination, loop

From: matlab_learner

Date: 19 Mar, 2010 01:30:19

Message: 1 of 1

I have to seek help after running out of resources on this.
I have a 39X39 tridiagonal matrix. We are not allowed to use Matrix
operations in matlab. we r using iterative methods to solve this.
We need to do gaussian elimintation on the system to solve it. It is
also called a PADE scheme.
We defined 3 vectors (a,b,c) for the matrix, each representing a
column in the matrix, and d vector for the rhs.

I found that for gauss elimination, the b entries (or B vector, which
is B=b*(1:39)) are overwritten and also the d (rhs) is overwritten.
However,my code doesn't seem to do justice to the results as the
results are way off what they should.
So here is the formula, and here is what I did. Can you pls point
whats wrong in the code? tnx.
the top row in the tri-diagonal matrix are just
(B(0) C(0) 0 0 0 0 0.... 0),
and the second row is (A(1) B(1) C(1) 0 0 0 0 0... 0)
the 3rd row is (0 A(2) B(2) C(2) 0 0 0 0 0 0...0),
ust like that till we get to the 39th row in the matrix
(0.....A(39) B(39) )
so for gauss elimination:
B(1) = B(1) - [C(0) * {A(1) / B(0) } ]
.
.
B(39) = B(39) - [C(38) * {A(39) / B(38) } ]

u do the same for the d(rhs) vector so
d(1) = d(1) - d(0)*{A(1) / B(0)}
.
.
d(39) = d(39) - d(38) * { A(39) / B(38) }

that is the given formula.

so given a = 12.5, b = 1, c = -12.5, i make my A B C vector (A =
12.5*ones(1,39) ), etc
I did:
while i<39
    B(i)=B(i) - C(i-1)*A(i)/B(i-1);
    % d(i)=d(i) - d(i-1)*(A(i)/B(i-1))
    i = i+1;
end
i = 2;
while i<39
    % B(i)=B(i) - C(i-1)*(A(i)/B(i-1));
    d(i)=d(i) - d(i-1)*(A(i)/B(i-1));
    i = i+1;
end


but the results are off...any ideas what i am doing wrong? tnx

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com