USING MATLAB Write a script for Gaussian elimination The use

USING MATLAB:

Write a script for Gaussian elimination. The user should input the A matrix and the B matrix. It should also check if the column of A matches the row of B. Finally, compare result using MATLAB function inv(). A = input(\'Please enter matrix A\') B = input(\'Please enter matrix B\')

Solution

% Code from \"Gauss elimination and Gauss Jordan methods using MATLAB\" % https://www.youtube.com/watch?v=kMApKEKisKE a = [3 4 -2 2 2 4 9 -3 5 8 -2 -3 7 6 10 1 4 6 7 2]; ------------------------------------ %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\'
USING MATLAB: Write a script for Gaussian elimination. The user should input the A matrix and the B matrix. It should also check if the column of A matches the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site