Let the future tell the truth and evaluate each one according to his work and accomplishments. The present is theirs; the future, for which I really worked, is mine. (Nikola Tesla)
Showing posts with label coefficient matrix. Show all posts
Showing posts with label coefficient matrix. Show all posts

15/05/2011

●Gauss Elimination Method using Matlab for Numerical Analysis

Here is the code to implement Gauss Elimination Method. The program asks for order of the system, coefficient matrix and right hand side vector. Then, it prints out the the augmented matrix after each forward elimination step and prints out the solutions after back substitution.


n=input('Order of the system= ');

A=input('Coefficient matrix= ');

B=input('Right hand vector= ');

X=input('Initial Estimate= ');

tol=input('Tolerance= ');

N=X;

for a=1:100

for i=1:n

z=0;

for t=1:i-1

z=z+(A(i,t)*X(t));

end

for t=i+1:n

z=z+(A(i,t)*X(t));

end

N(i)=X(i);

X(i)=(B(i)-z)/A(i,i);

end

X

if(abs((X(i)-N(i))/X(i))

end

end

ShareThis