How to implement "run" command with inputs
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
yySBU
am 17 Jul. 2018
Kommentiert: Walter Roberson
am 18 Jul. 2018
Hello
I've been trying to run a different script with a function header but I realized that I need to pass parameters as well. I would like the script name to be a variable so I cannot just type out the script name and put parenthesis to run that script. How would I go about doing this?
I have tried:
run(scriptVariable(parameter1, parameter2));
matlab -r scriptVariable(parameter1, parameter2);
But both don't work. I have also tried using eval but I couldn't insert object parameters.
Thank you
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 17 Jul. 2018
It is never possible to pass parameters with run() .
It is never possible to pass parameters to a script.
If you have the unqualified name of a function as a string, you can get a handle to the function using str2func .
If you have a path to a function (that is, including directory information) then you would have to use techniques similar to what run() does to cd into the containing directory; you could then take a handle to the function using str2func() .
3 Kommentare
Walter Roberson
am 18 Jul. 2018
Using a class is a potential solution. But I did not see any particular reason in your question why you could not just use a regular function.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Whos finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!