Evaluate a list of functions without using feval in generated code for embedded application
古いコメントを表示
I want to generate a mex function to evaluate a list of matlab functions iterativeley. The functions to evaluate are stored in a cell variable 'functionsList', each element being the name of the function file (char type). The code below works fine but it uses the 'feval' function which is an extrinsic one.
function outputs = functionToGenerate(inputs)
global functionsList
outputs = inputs;
for i=1:length(functionsList)
outputs = feval(functionsList{i},outputs);
end
end
As the final goal is to use this code for embedded application I am looking for an alternate method. I tried to use the 'str2func' with the code below :
function outputs = functionToGenerate(inputs)
global functionsList
outputs = inputs;
for i=1:length(functionsList)
f = str2func(functionsList{i});
outputs = f(outputs);
end
end
but I get an error during code generation :
Non-constant expression or empty matrix. This expression must be constant because its value determines the size or class of some expression.
This error concerns the line using 'str2func'. Can anyone could tell me where does the error come from and how can I solve this?
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で MATLAB Coder についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!