Evaluate a list of functions without using feval in generated code for embedded application
Mostra commenti meno recenti
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?
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su MATLAB Coder in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!