Set up tolerance and maximal iteration number for lsqlin
6 次查看(过去 30 天)
显示 更早的评论
Hello, I have a system of linear equations L*X=R and I try to use lsqlin to get the solution with least square. The system of equations is composed of more equations than the unknowns but there should exist a unique solution to this problem. The question is how should I set up the maximal number of iteration and the tolerance of termination for lsqlin. I tried to use
options = optimoptions('lsqlin','Algorithm','interior-point','MaxIter',10000,'StepTolerance',1e-10);
[X,res] = lsqlin(L,R,[],[],[],[],[],[],[],options);
What I want is to set up an exit tolerance for norm(L*X-R). Is it possible?
Many thanks
1 个评论
John D'Errico
2018-2-26
A question I would ask is if you have more equations than unknowns, then why do you expect an exact solution? That would seem to be unusual.
I would also echo Star's comment, as to why you are using lsqlin to solve an unconstrained problem that is trivially solved using backslash, lsqr, pinv, lsqminnorm, etc. Worrying about how to set the parameters on lsqlin seems to suggest that your matrix L is rank deficient. So there are several reasons that suggest lsqlin may be a poor choice of solution method.
采纳的回答
Star Strider
2018-2-26
The lsqlin function is designed solve constrained linear problems. You have specified no constraints, so it would be more appropriate to use the mldivide,\ (link) function, or if you have a sparse system, the lsqr (link) function.
Example —
X = L\R;
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Least Squares 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!