fminsearch in Matlab classes for code generation
8 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!