how to add a constraint condition to fsolve?
Mostra commenti meno recenti
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!
Risposta accettata
Più risposte (3)
Sean de Wolski
il 19 Nov 2013
1 voto
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
il 20 Nov 2013
1 voto
Alan Weiss
MATLAB mathematical toolbox documentation
1 Commento
Diptangshu Paul
il 11 Dic 2025
Right, lsqnonlin is a great improvement over the existing strengths of fsolve.
Categorie
Scopri di più su Solver Outputs and Iterative Display in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!