Gauss jordan elimination in Matlab using provided stipulatio
Gauss jordan elimination in Matlab using provided stipulations.
To use MATLAB as an aid to implement Gauss-Jordan elimination. To gain experience in writing MATLAB script m-files. Write a MATLAB script m-file that applies Gauss-Jordan elimination to A = [A b] with A = [-1 2 -1 1 3 -6 3 -3 1 0 2 2 1 2 3 5] b = [-5 8 -6 2] for the purpose of solving the linear system of equations Ax = b. Download the MATLAB script m-file gauss_jordan elimination_example.m from the Presentations area in Blackboard and use it as a guide to get started. Rename the file as \'exercise2.m\' and update the comment header to include your name. Implement the row operations necessary to transform [A] = [A B] into [R] = [R f] in reduced row echelon form. Have your script compare your final reduced row echelon form to that produced by the MATLAB command. Contents of gauss_jordan_elimination_example.m: A=[-1 3 1 1;2 -6 0 2;-1 3 2 3;1 -3 2 5] b=[-5;8;-6;2] Ab=[A b]Solution
I write a Matlab code for Gauss Jordan Elimination Method to solve the problem.
%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\'
