I am trying to use LSQR on matlab to solve a linear equations:
$$
aX + bY = Z
$$
so I form [a b][X Y]' = Z where a, b and Z are row vectors.
I am testing it on simulation i.e controlled data.
A = [a,b];
XY = lsqr(A,Z,1e-14,100);
However, I cant seem to get the right value for $X$ and $Y$. Is there any condition I should check for for my matrix A? The calculation converges at iteration number 2 with residual in the order of e-14. But the value is wrong.
Kelvin
$Z$ must be a column vector. It actually gives an error message if you try to use a row vector, so the mistake might be that you used the wrong entry on
lsqr.Also, the LSQR method doesn't actually solve $Ax=b$, but minimizes $||Ax-b||$ and gives the solution $x$ with lower norm. The result you got is correct, you're probably just interpreting it the wrong way, for example, by checking if it solves $aX + bY = Z$.