I see in the MATLAB help (matlab -h) that I can use the -r flag to specify an m-file to run. I notice when I do this, MATLAB seems to start the script, but immediately return. The script processes fine, but the main app has already returned.
Is there any way to get MATLAB to only return once the command is finished? If you're calling it from a separate program it seems like it's easier to wait on the process than to use a file or sockets to confirm completion.
To illustrate, here's a sample function waitHello.m
:
function waitHello
disp('Waiting...');
pause(3); %pauses 3 seconds
disp('Hello World');
quit;
And I try to run this using:
matlab -nosplash -nodesktop -r waitHello