Hi, In LU Decomposition method we try to convert A matrix to echleon form by using gauss elimination method. The code starts from the first row, tries to find the factor by which we need to multiply the current row and subtract it from the rows below it, to make the elements in the Lower Triangular Matrix as zeros.
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);
The above code iterates till all the elements in Lower Triangular matrix becomes zero. Later we get the tril and triu of A, which gives L and U matrices.
I suggest using breakpoints, and work on this program. To know the updation of A for each iteration.
Hope this helps!