Computational Science Community Wiki

Running Matlab on Mace01

A Simple Example

Here is an example SGE submission script for use with Matlab — we assume it is saved as

#$ -cwd
    # ...use the current working directory --- from where you type
    #    "qsub" --- 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

    saveas(gcf, 'myfig', 'fig')

To submit the job to the batch system:

    prompt> qsub

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 (R2007b)
                               August 9, 2007

    To get started, type one of these: helpwin, helpdesk, or demo.
    For product information, visit

    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.