Pre-Engineering 220 Introduction to MatLab ® & Scientific Programming j kiefer



Download 8.69 Mb.
Page52/128
Date02.05.2018
Size8.69 Mb.
#47255
1   ...   48   49   50   51   52   53   54   55   ...   128

4. Gauss-Jordan Elimination

a. Inverse matrix



We might multiply all the elementary matrices together before multiplying by the augmented matrix. That is, carry out the evaluation of , then perform .


% Script to implement Gauss-Jordan Elimination

b=[4 1 2;1 3 1;1 2 5];

c=[16;10;12];

a=[b c];


np=size(b);

n=np(1);


for k=1:n

for m=k+1:n+1

a(k,m)=a(k,m)/a(k,k);

end


a(k,k)=1;

for l=1:n

if l~=k

for m=k+1:n+1



a(l,m)=a(l,m)-a(l,k)*a(k,m);

end


a(l,k)=0;

end


end

end


a

b. Algorithm





Download 8.69 Mb.

Share with your friends:
1   ...   48   49   50   51   52   53   54   55   ...   128




The database is protected by copyright ©ininet.org 2024
send message

    Main page