1 2 3 4 5 6 7 8 9 10 11 12
function [U,L]=LandU(A,n) U=A L=eye(n,n) for p=1:1:n-1 for i=p+1:1:n m=A(i,p)/A(p,p); L(i,p)=m; A(i,:)=A(i,:)-m*A(p,:); U=A; end end endfunction