how to add a constraint condition to fsolve?
Mostrar comentarios más antiguos
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!
Respuesta aceptada
Más respuestas (3)
Sean de Wolski
el 19 de Nov. de 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
el 20 de Nov. de 2013
1 voto
Alan Weiss
MATLAB mathematical toolbox documentation
1 comentario
Diptangshu Paul
el 11 de Dic. de 2025
Right, lsqnonlin is a great improvement over the existing strengths of fsolve.
Categorías
Más información sobre Solver Outputs and Iterative Display en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!