fminsearch in Matlab classes for code generation
Afficher commentaires plus anciens
I am designing a Matlab class to do some optimization and I am using fminsearch. I want to put it into a user-defined Matlab function in Simulink. I know the anonymous functions have issues with code generation so I constructed the objective function as a class method so I can avoid using the anonymous function. Then, I ended up with something like fminsearch(@obj.objFunc,x,options). Everything works fine in a little unit test I wrote in Matlab script. However, after I put it into the user-defined Matlab function in Simulink, it complains that "code generation does not support function handles pointing to non-static methods." I cannot change the attribute of my objective function into "static", since it requires the information of other variables of the class properties. So how I can use fminsearch in a Matlab class with code generation? Thanks.
Réponses (1)
A.rahim Baram
le 31 Mai 2021
0 votes
y^2+x^2
Catégories
En savoir plus sur Performance dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!