Set up tolerance and maximal iteration number for lsqlin
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaire
John D'Errico
le 26 Fév 2018
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.
Réponse acceptée
Star Strider
le 26 Fév 2018
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Linear Least Squares dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!