MATLAB: How do you get a general solution of and underdetermined system

underdetermined system

How can you obtain the general solution of an underdetermined system? What I have now is:
A=[1 2 3;-2 -1 0;0 2 4];
b=[5;-1;6];
x=A\b
but this gives me the answer x =
NaN
NaN
NaN
hope someone can help me

Best Answer

I would use the pseudo-inverse pinv function:
x = pinv(A)*b
x =
166.6667e-003
666.6667e-003
1.1667e+000
There may be other options, such as the sparse matrix lsqr funciton, which gives the same result:
x = lsqr(A,b)
Related Question