fminsearch in Matlab classes for code generation

조회 수: 8 (최근 30일)
ZK
ZK 2016년 11월 17일
답변: A.rahim Baram 2021년 5월 31일
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.

답변 (1개)

A.rahim Baram
A.rahim Baram 2021년 5월 31일
y^2+x^2

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by