MATLAB: What is the difference between starting a MATLAB script from MATLAB or from a batch/shell script

MATLAB

I would like to know the difference between starting a .m script directly in MATLAB or start it with the -r option from a batch file / shell script with the -r option.

Best Answer

This difference has been removed in MATLAB 7.4 (R2007a). If you are using a previous version, read the following:
When starting MATLAB with the -r option from a batch file or a shelll script, the MATLAB initialization has not been performed completely. To work around this behavior, add a PAUSE command to your script or start MATLAB using this command:
matlab -r "pause(10); myscript"