Running Matlab on Mace01
Matlab jobs run on Mace01 must be submitted to the batch/queue system, SGE ‐ Matlab must not be used interactively on Mace01.
- To use Matlab with SGE, there are three steps: write a SGE submission script; write a Matlab batch file; and finally, use the "qsub" command to submit the job to the batch system. Examples are given below.
The version of Matlab installed on Mace01 does not have any parallel functionality, so jobs should be submitted to either the serial-short.q queue (for short, test jobs of up to one hour) or the serial.q (for all other jobs).
Matlab is installed in /software/matlab — this is a link to /software/matlab_R2007b. It is expected that should a newer version of Matlab be installed, the link will be updated to point to this newer version.
A Simple Example
Here is an example SGE submission script for use with Matlab — we assume it is saved as runmatlab.sh:
#$ -cwd # # ...use the current working directory --- from where you type # "qsub runmatlab.sh" --- to run the job... # #$ -q serial.q # # ...tell SGE to run the job within the "serial.q" queue... # /software/matlab/bin/matlab < myinput.m # # ...the job consists of running the above command, i.e., run # Matlab in batch mode with "myinput.m" as the input file/script...
The Matlab input file/script is simply a list of Matlab commands, such as
x=1:5 y=x.^2 plot(x,y) saveas(gcf, 'myfig', 'fig')
To submit the job to the batch system:
prompt> qsub runmatlab.sh
With the SGE submission script given above, standard output from the job, i.e., "screen" output, is sent to matlab_output, viz
Warning: No display specified. You will not be able to display graphics on the screen. < M A T L A B > Copyright 1984-2007 The MathWorks, Inc. Version 188.8.131.528 (R2007b) August 9, 2007 To get started, type one of these: helpwin, helpdesk, or demo. For product information, visit www.mathworks.com. >> x = 1 2 3 4 5 >> y = 1 4 9 16 25 >>
With the Matlab input file/script given above, the graphic is output to a file called myfig.fig as specified in the saveas command.