Home > Mobile >  Matlab str2func calling a mex file and getting input variable error
Matlab str2func calling a mex file and getting input variable error

Time:04-28

I have a mex-function specialRationalMap_00001.mexw64, that can be called without problems

vm = specialRationalMap_00001(vm,amplitude);

If I am trying to use the function name and str2func

f_str = 'specialRationalMap_00001';
fz = str2func(strcat('@(vm,amplitude)', f_str));
vm = fz(vm,amplitude);

I got the error: "A map input and a (scalar) amplitude required", but I am using exactly this as input.

CodePudding user response:

Dont forget to actually pass the input arguments. Either do

fz = str2func(strcat('@(vm,amplitude)', f_str, '(vm,amplitude)'));

But better, you can just do:

fz = str2func(f_str);
  • Related