Set up tolerance and maximal iteration number for lsqlin

조회 수: 6 (최근 30일)
Xin
Xin 2018년 2월 26일
댓글: John D'Errico 2018년 2월 26일
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
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
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개)

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by