How can I have a script open a new MATLAB instance and run a different script in that new instance?
Show older comments
The title pretty much says it, I am trying to write a scirpt file that will, upon execution, open a new instance of MATLAB and have that new instance run a different script. I currently have the following:
system('"C:\Program Files\MATLAB\R2024a\bin\matlab.exe" -r "run("SecondScript.m")"')
I based this on the answer to a somewhat similar forum post I found, but have not been able to get it to work properly. Executing this line successfully opens the new MATLAB instance and seems to try running SecondScript.m, but throws an Unable to resolve the name 'SecondScript.m' error in the new instance. I'm fairly unfamiliar with the use of the system function and the -r flag, so any help would be appreciated.
I'll also add that I am aware that the Parellel Computing Toolbox can do something similar, however that is not an option for me.
1 Comment
Walter Roberson
on 30 Jul 2024
Edited: Walter Roberson
on 30 Jul 2024
system('"C:\Program Files\MATLAB\R2024a\bin\matlab.exe" -r "run(''SecondScript.m'')"')
This leaves open the question of which directory MATLAB is going to start in. It is probably more robust to name the full path to the script file.
Accepted Answer
More Answers (0)
Categories
Find more on File Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!