I created an upper triangular matrix in U and a lower triangular matrix L from A matrix but when I go to make the inverse procedure in order to take my original matrix the matlab returns the right elements in right row and column but the rows are in wrong place. What I do wrong?
A=[1 -2 3;9 2 1;4 -3 2]
[L,U,P]=lu(A)
B=P*A
C=L*U
A =
1 -2 3
9 2 1
4 -3 2
L =
1.0000 0 0
0.4444 1.0000 0
0.1111 0.5714 1.0000
U =
9.0000 2.0000 1.0000
0 -3.8889 1.5556
0 0 2.0000
P =
0 1 0
0 0 1
1 0 0
B =
9 2 1
4 -3 2
1 -2 3
C =
9 2 1
4 -3 2
1 -2 3