Wait until another instance of MATLAB is finished executing

1 view (last 30 days)
I am running a secondary MATLAB instance from within my primary MATLAB window:
% in the primary MATLAB instance
eval(['!matlab -nodesktop -r execute(' input ')&']) % this runs execute.m in the secondary MATLAB instance
where execute(input) is a function that calls for a variable named input.
While the execution time of the secondary instance (i.e. execute.m) could be quite long, I would like the primary instance to wait until this execution is finished.
Note: I know I can fetch the PID and number of different MATLAB consoles (instances) running in the system at each moment via
[status,result] = system('tasklist /FI "imagename eq matlab.exe" ')
and wait until the number of instances/PID is equivalent to what it was before opening any secondary instances, but is there any better way to address this issue?

Answers (0)

Categories

Find more on Get Started with MATLAB 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!