MATLAB is a high-level language and interactive environment that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran.

The MATLAB home page is at

Licence information


MATLAB is made available to researchers under commercial licence agreements with individuals, research groups, departments, faculties or institutions. Whether you have access to MATLAB, which versions you have access to, and under what conditions, will vary depending on where you work or study. If you have any questions regarding your eligibility to access MATLAB or any particular version of it, please contact our support desk.

Licence rationing

Some institutions only have a limited number of MATLAB licence tokens. To ensure that there are always enough of these tokens remaining for interactive work and for scheduled jobs to start sucessfully, we request that users from Massey University inform Slurm of their jobs' licence requirements:

  • Massey University: #SBATCH --licenses=massey_matlab:1

Licence status

If you get an error message indicating that no licenses are available for a certain feature, you can use a command like the following to check the licensing situation. The output will show you the licensing situation for individual features.

lmutil lmstat -a

Example script

Simple script.

#!/bin/bash -e
#SBATCH --job-name   MATLAB_job   #Name to appear in squeue 
#SBATCH --time 01:00:00 #Max walltime
#SBATCH --mem 1500 #Max memory

module load MATLAB/2018b
# Run the MATLAB script MATLAB_job.m
matlab -nodisplay < MATLAB_job.m

Extended paths script.

#!/bin/bash -e
#SBATCH --job-name       MATLAB_job    #Name to appear in squeue
#SBATCH --time 06:00:00 #Max walltime
#SBATCH --mem 6000 #Max memory
#SBATCH --cpus-per-task 4 #2 physical cores.
#SBATCH --output %x.log #Location of output log

module load MATLAB/2018b

#Job run
matlab -nodisplay -r "addpath(genpath('../parentDirectory'));myFunction(5,20)"



Implicit parallelism.

By default MATLAB will utilise multi-threading for a wide range of operations

MATLAB does not support MPI therefore #SBATCH --ntasks should always be 1, but if given the necessary resources some MATLAB functions can make use of multiple threads (--cpus-per-task) or GPUs (--gres gpu). If you use the higher-level parpool-based language constructs such as spmd and parfor MATLAB will make temporary files under your home directory (in ~/.matlab/local_cluster_jobs) for communication with worker processes. To prevent simultaneous such parallel MATLAB jobs from interfering with each other you should tell them to each use their own job-specific local directories:

pc = parcluster('local')
pc.JobStorageLocation = getenv('TMPDIR')
parpool(pc, str2num(getenv('SLURM_CPUS_PER_TASK')))

The same can be acheived from outside the MATLAB code with the quick hack of changing HOME:

HOME=$TMPDIR matlab ...
Labels: mahuika tier1 engineering general app
Was this article helpful?
1 out of 1 found this helpful