clc clear all a=[]; n=length(a); A_inv=zeros(n,n); for m=1:n a=[-1 3 2;1 -2 1;1 -1 1]; b=[0; 0; 0]; b(m)=1; for k=1:n-1 for i=k+1:n; factor=a(i,k)/a(k,k); for j=k+1:n a(i,j)=a(i,j)-factor*a(k,j); end b(i)=b(i)-factor*b(k); end end x(n)=b(n)/a(n,n); A A_in