function [A,C]=luFromClass(A) % This is the decomposition we talked about in class. Calling this % function produces the upper triangular matrix U and a matrix of constants % C. % %Example useage: % A=[1 2 -1;2 1 -2;-3 1 1]; % [U,L]=luFromClass(A); % % Exam problem: Change the code below so that you get the lower triangular % matrix L instead of the constant matrix C. See page 86 for an example of % what the example above should give you. [m,n]=size(A); C=zeros(m,n); for k=1:n-1 for j=k+1:n if A(k,k)~=0 %Be sure we're not dividing by zero C(k,j)=-A(j,k)/A(k,k); A(j,:)=C(k,j)*A(k,:)+A(j,:); else error('Zero pivot in Z'); end end end