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!