Let A
be the following matrix:
1 3
2 4
if I call the lu( )
function and save the return values like this:
[L, U] = lu(A);
MATLAB returns L, U such that L * U = A:
>> L * U
ans =
1 3
2 4
While when I save the return values like this:
[L, U, P] = lu(A);
L * U is not equal to A:
>> L * U
ans =
2 4
1 3
because lu( )
returns L, U, P such that L * U = P * A
My questions:
- How can the
lu( )
function know how many return parameters I have asked for? - Can I replicate this behavior in my code?