% Code from 'Gauss elimination and Gauss Jordan methods using MATLAB' |
% https://www.youtube.com/watch?v=kMApKEKisKE |
a = [34 -222 |
49 -358 |
-2 -37610 |
14672]; |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
%Gauss elimination method [m,n)=size(a); |
[m,n]=size(a); |
for j=1:m-1 |
for z=2:m |
if a(j,j)0 |
t=a(j,:);a(j,:)=a(z,:); |
a(z,:)=t; |
end |
end |
for i=j+1:m |
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j)); |
end |
end |
x=zeros(1,m); |
for s=m:-1:1 |
c=0; |
for k=2:m |
c=c+a(s,k)*x(k); |
end |
x(s)=(a(s,n)-c)/a(s,s); |
end |
disp('Gauss elimination method:'); |
a |
x' |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
% Gauss-Jordan method |
[m,n]=size(a); |
for j=1:m-1 |
for z=2:m |
if a(j,j)0 |
t=a(1,:);a(1,:)=a(z,:); |
a(z,:)=t; |
end |
end |
for i=j+1:m |
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j)); |
end |
end |
for j=m:-1:2 |
for i=j-1:-1:1 |
a(i,:)=a(i,:)-a(j,:)*(a(i,j)/a(j,j)); |
end |
end |
for s=1:m |
a(s,:)=a(s,:)/a(s,s); |
x(s)=a(s,n); |
end |
disp('Gauss-Jordan method:'); |
a |
x' |
what is the difference bw gauss Jordan method and gauss Jordan elimination |
in line 14 , it will be for z=j+1:m otherwise for z=2:m will not work for a=[2 1 -1 2 5 4 5 -3 6 9 4 2 -2 9 8 4 11 -4 8 2]; |
a(j,:) means? |
Can i get the matlab gui implementation of gauss elimination ? |
Good job |
if your matrix is changed as shown below, does your program work? a = [3 4 -2 2 2 4 0 -3 5 8 -2 -3 0 6 10 1 4 6 7 2]; thanks |
Can we find inverse using this method ? What is the final output which we get ? |