Why do I get an error when using 'fmincon' in Simulink?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 28 Fév 2022
Réponse apportée : MathWorks Support Team
le 28 Fév 2022
I'm using MATLAB R2021b and try to implement 'fmincon' in MATLAB Function block like below.
x = fmincon(fun,x0,A,b);
However, I get an error when I run simulation.
FMINCON requires 10 input arguments. Pass OPTIMOPTIONS to the solver with property 'Algorithm' set to 'sqp'.
How can I escape the error?
Réponse acceptée
MathWorks Support Team
le 28 Fév 2022
If you use 'fmincon' in MATLAB Function block, you have to write codes in a special manner, because the MATLAB Function block relies on code generation technology.
The limitation is written in this document.
You should set an option and pass 10 arguments to 'fmincon'.
options = optimoptions('fmincon', 'Algorithm', 'sqp');
x = fmincon( fun , x0 , A , b , Aeq , beq , lb , ub , nonlcon , options )
Note:
Additional arguments like Aeq, beq,... can be empty: [].
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Solver Outputs and Iterative Display 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!