Function names and parameters in Matlab variables
In my matlab ml file I am using some logic (string concat) to create variables like this:
c = 'CalcPrediction(1,10)'
This means that I have a string which is a function and some parameters. How can I make this function call?
Attempting to run (c) results in:
>> run(c)
??? Error using ==> run at 71
CalcPrediction(1,10) not found.
Note: run (c) works fine if there are no parameters. For example. c = 'CalcPrediction'; execution (s);
source to share
Without actually looking at the script, it's hard to generalize, but ...
Where squareRoot is m file containing only: y=sqrt(x)
Then it runs:
x=[2,0];
c='squareRoot';
run(c);
gives:
y =
1.4142 0
This example means that you can define a script to use the declared variable ( x
in this case) and then declare the variable before running the script.
Without the script, I don't know what you are doing with the parameters. If that doesn't answer your question, please post to the script.
source to share