how to add a constraint condition to fsolve?
Ältere Kommentare anzeigen
Hi everyone,
These days I want to solve a system of nonlinear equations with matlab. In the equations, there are all four unkonwns, A(1),A(2),A(3)and A(4) to be solved but only three equations. therefore, the 'levenberg-marquardt' algorithm is applied to get the results. However, for physical meaning, an additional constraint is required, i.e. A(3)should be larger than zero. and with the 'levenberg-marquardt' algorithm, in the the obtained result, A(3) is negative.
Does anyone know how to add this constraint condition to fsolve ? Your help will be highly appreciated!
Akzeptierte Antwort
Weitere Antworten (3)
Sean de Wolski
am 19 Nov. 2013
1 Stimme
fsolve does not provide the ability to use constraints. You'll need fmincon for this.
However, for physical meaning, an additional constraint is required, i.e. A(3)should be larger than zero.
If your constraints are simply non-negativity and bound constraints, you should probably use lsqnonlin. lsqnonlin is a bit more specialized than fmincon, and there may be advantages to that.
lsqnonlin is also set up to take exactly the same objective function format as fsolve, whereas fmincon doesn't.
Alan Weiss
am 20 Nov. 2013
1 Stimme
Alan Weiss
MATLAB mathematical toolbox documentation
1 Kommentar
Diptangshu Paul
am 11 Dez. 2025
Right, lsqnonlin is a great improvement over the existing strengths of fsolve.
Kategorien
Mehr zu Solver Outputs and Iterative Display finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!