Overloaded feval function with cfit object when using Compiler

I'm attempting to compile an m-file that uses the overloaded feval or predict MATLAB functions.
My code currently evaluates a cfit object loaded from a .mat file the following way:
load some_cfit_object.mat
y = feval(some_cfit_object, x);
This works perfectly fine in MATLAB. However, once compiled, I get the following error when running the dll:
"Function to evaluate must be represented as a string scalar, character vector, or function_handle object".
This happens, because the MCR is using the generic feval function instead of the @cfit/feval function.
What is the best way to solve this issue?

 채택된 답변

Benjamin Thompson
Benjamin Thompson 2022년 2월 2일

0 개 추천

The dependency scanner cannot look into arguments passed to feval very well, per the MATLAB Compiler User Guide. Use the %#function directive in your code to explicitly list dependencies on functions or class types that feval will use.

댓글 수: 3

Thank you. I did read through that, but I do not understand the syntax to specfify the feval.m from the CurveFit function. The following has no effect:
%#feval
In your M flie add something like
%#function function_name
%#function class_name
Here, class_name might be the class type of the object from the MAT file that you are passing to feval. It is not clear from your description what that class type is.
The following is needed to use feval with a cfit object:
%#function feval
%#function cfit

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Big Data Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by