What versions of MATLAB are available?

Run one of the commands below, which will list available versions and the corresponding module files:

module spider matlab

How do I select a version?

Load the appropriate module file. For example, to run version R2014a:

module load Apps/Matlab/R2014a

The module load command sets up your environment, including the PATH to find the proper version of the MATLAB program.

How do I run MATLAB?

Be sure to run MATLAB on a compute node, not a login node. You can use up to all the cores on a single node without any special Matlab setup (though your sbatch command will need to specify the number of cores you intend to use).

To run MATLAB interactively:

To run Matlab interactively, you need to create an interactive session on a compute node.

You could start an interactive session using 4 cores on 1 node using something like

srun --pty --x11 -c 4 -p interactive -t 4:00:00 bash

Once your interactive session starts, you can load the appropriate module file and start Matlab as described above.

To run MATLAB in batch mode (without a GUI):

Create a batch script containing both instructions to the scheduler and shell instructions to set up directories and start Matlab. At the point you wish to start Matlab, use a command like:

matlab -nodisplay -nosplash -r YourFunction < /dev/null

This command will run the contents of YourFunction.m. Your batch submission script must either be in or cd to the directory containing YourFunction.m for this to work.

Below is a sample batch script to run Matlab in batch mode on Grace. If the name of the script is, you would submit it using


Here's a script for Grace:

#SBATCH -J myjob
#SBATCH -c 4
#SBATCH -t 24:00:00
#SBATCH -p day

module load Apps/Matlab/R2016b
matlab -nodisplay -nosplash -r YourFunction < /dev/null

Unless you specify otherwise (using > redirects), both output and error logs will show up in the slurm-jobid.out log file in the same directory as your submission script.

Using More than 12 Cores with Matlab

In Matlab, 12 workers is a poorly documented default limit (seemingly for historical reasons) when setting up the parallel environment. You can override it by explicitly setting up your parpool before calling parfor or other parallel functions.


What is MCDE?

The Matlab Distributed Computing Engine (MDCE) allows users to run parallel Matlab computations over multiple cluster compute nodes. To run parallel Matlab computations on any number of cores of a single compute node, please use ordinary Matlab (not MDCE) as described above to avoid tying up our limited number of licenses for MDCE.

MDCE is installed on all the HPC clusters, and we provide scripts to make it easy to use. Currently, our license for MDCE is restricted to a total of 32 concurrent labs per cluster (aggregated over all jobs using MDCE on the cluster), plus an additional 128 licenses that float and are available on any of the clusters when the cluster-specific licenses are already in use.

How do I get started using the MCDE?

The first step required for use of MDCE is to develop a parallel Matlab program using the Parallel Computing Toolbox (PCT). The PCT allows you to run parallel computations either on a single node or across multiple nodes. In most cases, before running on multiple nodes, you should develop and test your algorithm on a single node using multiple cores.

For the single-node case, you simply run ordinary Matlab as described above (either interactively or in batch mode) and make use of the PCT commands using the "local" cluster configuration. This capability is enabled for any Matlab invocation on any of the clusters, and there are no limitations on the number of concurrent PCT users in this case. If you intend to run on a single node, therefore, please do not use MDCE, since that would consume some of our limited quantity of multi-node MDCE licenses.

For the multi-node case, you must run an MDCE server that is private to your job. We provide a script ( that starts the server and the Matlab workers (known as "labs") for you. The script has parameters that allow you to control the number of labs on each node, subject to license availability. (For details, see the comments in the file shown later on this page.) The MDCE server will be terminated automatically when your cluster job ends, though we also provide a script ( to terminate it earlier if you wish. The yale_mdce scripts will be in your PATH once you have loaded a Matlab module file (e.g., Apps/Matlab/R2015a). To use the script, you need to load module files for both Matlab and OpenMPI (see the script below for an example).

We have also developed a template batch script ( that you can submit to the job scheduler to run your parallel Matlab program. The script loads module files, invokes, and then runs Matlab in batch mode. You can copy the template and and customize it to meet your needs. If you prefer to run interactively, you can start an ordinary multi-node interactive session (similar to what's shown above) and run the setup commands in by hand. (for Slurm)


#SBATCH --ntasks=25
#SBATCH --time=24:00:00
#SBATCH --partition=day

# Load Matlab and MPI module files
module load Apps/Matlab/R2015a MPI/OpenMPI

# Invoke to set up a job manager and MDCE server
# Note: and runscript.m are in the MDCE_SCRIPTS subdirectory of the root Matlab directory (e.g., /home/apps/fas/Apps/Matlab on Omega). 
#       The MDCE_SCRIPTS directory is added to your PATH by the Matlab module file loaded above.

# Options for

# -jmworkers: number of labs to run on same node as the job manager. 
# "-jmworkers NN" runs NN labs on job manager node
# "-jmworkers -1" run 1 fewer than labs than the number of cores allocated on the node
# Default: -1

# -nodeworkers: number of labs to run on nodes other than the job manager node.
# "-nodeworkers NN" runs NN labs on each node
# "-nodeworkers -1" run same number of labs as the number of cores allocated on each node
# Default: -1 -jmworkers -1 -nodeworkers -1


# invoke either runscript.m or your own M-file
# (You need to modify runscript.m first to run your computations!!)

# runscript.m uses the parallel cluster created by 
matlab -nodisplay < runscript.m

Example runscript.m



nw = p.NumIdleWorkers