Running MATLAB in Batch Mode

MATLAB jobs can be run in batch mode by passing MATLAB the sequence of commands. Here is an example shell script for bash shell users,

     #!/bin/sh

     DISPLAY=""
     export DISPLAY 
     matlab << END_TAG
       my_matlab_script.m  
       save my_matlab_output
       quit 
     END_TAG

     # Wait for any running jobs to finish.
     wait
The list of MATLAB commands are placed between the first and second END_TAG statements. Alternatively, one could just direct a normal MATLAB script as input to the matlab command.
     #!/bin/sh

     DISPLAY=""
     export DISPLAY
     matlab < my_matlab_script.m

     # Wait for any running jobs to finish.
     wait
Notes: