function [U] = GaussElim(A) %Gauss Elimination for Regular Matrix % This is certainly NOT the right way to do this with Matlab, which % has sophisticated matrix manipulation routines. This is provided % merely to illustrate the algorithm in Olver % % To use, create a matrix % > A = rand(5,10) % and type % > [U] = GaussElim(A) [m,n] = size(A); U = A; for j = 1:n % Choose jth column for i = j+1:m % Zero elements below pivot (j,j) if(U(j,j) == 0) error('%d th Pivot vanishes. Matrix is not Regular',j) end l = U(i,j)/U(j,j); for k = j:n % Rowk -> Row k - l*Row j U(i,k) = U(i,k) -l*U(j,k); end %U % uncomment this to print result after each row reduction end end