Skip to content
Snippets Groups Projects
title = "Submitting MATLAB Jobs"
description =  "How to submit MATLAB jobs on HCC resources."

Submitting Matlab jobs is very similar to submitting MPI jobs or serial jobs (depending if you are using parallela matlab).

Submit File

The submit file will need to be modified to allow Matlab to work. Specifically, these two lines should be added before calling matlab:

{{% panel theme="info" header="serial_matlab.submit" %}} {{< highlight batch >}} #!/bin/sh #SBATCH --time=03:15:00 #SBATCH --mem-per-cpu=1024 #SBATCH --job-name=[job_name] #SBATCH --error=/work/[groupname]/[username]/job.%J.err #SBATCH --output=/work/[groupname]/[username]/job.%J.out

module load matlab/r2014b matlab -nodisplay -r "[matlab script name], quit" {{< /highlight >}} {{% /panel %}}

Parallel Matlab .m file

The submit file:

{{% panel theme="info" header="parallel_matlab.submit" %}} {{< highlight batch >}} #!/bin/sh #SBATCH --nodes=1 #SBATCH --ntasks-per-node=5 #SBATCH --time=03:15:00 #SBATCH --mem-per-cpu=1024 #SBATCH --job-name=[job_name] #SBATCH --error=/work/[groupname]/[username]/job.%J.err #SBATCH --output=/work/[groupname]/[username]/job.%J.out

module load matlab/r2014b matlab -nodisplay -r "[matlab script name], quit" {{< /highlight >}} {{% /panel %}}

Matlab File Additions

In addition to the changes in the submit file, if you are running parallel Matlab, you will also need to add to the .m file the additional lines:

{{< highlight batch >}} ... i=str2num(getenv('SLURM_TASKS_PER_NODE')); parpool(i); ... {{< /highlight >}}