a=[3 7 -2 3 -1; 4 0 0 0 5; 0 0 5 -4 1; 2 0 9 4 3; 0 0 0 5 8];b=[37;40;12;14;20];c=[a b]np=size(c);n=np(2);for k=1:n for m=k+1:n+1 c(k,m)=c(k,m)/c(k,k); end c(k,k)=1; for l=1:n if l~=k for m=k+1:n+1 c(l,m)=c(l,m)-c(l,k)*c(k,m); end c(l,k)=0; end endendc
Error as shown: Index exceeds matrix dimensions.
Error in line 9 c(k,m)=c(k,m)/c(k,k);
Solving the linear equation without using "rref".
Best Answer