MATLAB: Matlab Coder error in C++ code generation

cembedded matlab functionfunctionfunction handleMATLABmatlab codermexmex compiler

I am building a pairs trading module where I am using the following line pfun = @(x) pairsFun(x, DATA1, DATA2, annual Scaling, cost);
this is probably creating a function handle pfun to function pairsfun where the next line [~,param] = parameterSweep(pfun,range);
passes the function as argument to another function parametersweep which loops to find maximum value of a variable. The code is taken from matlab pairs trading module.
The issue is when I am trying to generate codes for C++ using coder the line pfun = @(x) pairsFun(x, DATA1, DATA2, annual Scaling, cost); is generating an error : this kind of expression is not supported.
It would great if someone provides some direction.

Best Answer

Anonymous functions are not supported for codegen. You will have to work around this by using a function handle to a regular function or sub-function.
Related Question