Howto
Contents
How to do Matlab
... batch processing?
To call Matlab from the command line or a shell script and have it execute a command or a Matlab script call:
matlab -nojvm -nosplash -r [x,y,z]=script -logfile script.log > /dev/null
This must be called in a directory that contains a file script.m
. Whatever Matlab usually dumps to its console ends up
in the file script.log
. To make sure it does not show up in your script output stdout is redirected to /dev/null
.
The [x,y,z]=
part is only necessary if your script returns results which you would want to use somehow.
IMPORTANT: make sure your script contains an 'exit;' as last command! Otherwise this Matlab instance would remain running which might end up
with really nasty performance results in a loop statement. If a bunch of matlab scripts are to be executed, compile a master .m
-file which calls them (and is the only one that contains the 'exit;'). This way Matlab is not closed and restarted for each script which might gain a significant performance gain.