function [L,U,error]=mylu2(A)
N=length(A);
L=zeros(N);
U=zeros(N);
error=0;
for k=1:N-1
    if A(k,k)==0
        error=1;
        return
    end
    i=[k+1:N];
    A(i,k)=A(i,k)/A(k,k);
    A(i,i)=A(i,i)-A(i,k)*A(k,i);
end
U=triu(A);
L=eye(N)+tril(A,-1);