Skip to content

Matlab

Matlab is installed on DelftBlue as a software module and, unless it is absolutely crucial to display graphics, should be run from the command line. If you want to work with a graphical interface, you can find MATLAB under "Interactive Apps" on our online portal OpenOndemand.

Which toolboxes are included?
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 24.2.0.2833386 (R2024b) Update 4
MATLAB License Number: 329139
Operating System: Linux 4.18.0-553.44.1.el8_10.x86_64 #1 SMP Wed Mar 5 10:48:41 EST 2025 x86_64
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB                                                Version 24.2        (R2024b)
Simulink                                              Version 24.2        (R2024b)
5G Toolbox                                            Version 24.2        (R2024b)
AUTOSAR Blockset                                      Version 24.2        (R2024b)
Aerospace Blockset                                    Version 24.2        (R2024b)
Aerospace Toolbox                                     Version 24.2        (R2024b)
Antenna Toolbox                                       Version 24.2        (R2024b)
Audio Toolbox                                         Version 24.2        (R2024b)
Automated Driving Toolbox                             Version 24.2        (R2024b)
Bioinformatics Toolbox                                Version 24.2        (R2024b)
Bluetooth Toolbox                                     Version 24.2        (R2024b)
C2000 Microcontroller Blockset                        Version 24.2        (R2024b)
Communications Toolbox                                Version 24.2        (R2024b)
Computer Vision Toolbox                               Version 24.2        (R2024b)
Control System Toolbox                                Version 24.2        (R2024b)
Curve Fitting Toolbox                                 Version 24.2        (R2024b)
DDS Blockset                                          Version 24.2        (R2024b)
DSP HDL Toolbox                                       Version 24.2        (R2024b)
DSP System Toolbox                                    Version 24.2        (R2024b)
Database Toolbox                                      Version 24.2        (R2024b)
Datafeed Toolbox                                      Version 24.2        (R2024b)
Deep Learning HDL Toolbox                             Version 24.2        (R2024b)
Deep Learning Toolbox                                 Version 24.2        (R2024b)
Econometrics Toolbox                                  Version 24.2        (R2024b)
Embedded Coder                                        Version 24.2        (R2024b)
Filter Design HDL Coder                               Version 24.2        (R2024b)
Financial Instruments Toolbox                         Version 24.2        (R2024b)
Financial Toolbox                                     Version 24.2        (R2024b)
Fixed-Point Designer                                  Version 24.2        (R2024b)
Fuzzy Logic Toolbox                                   Version 24.2        (R2024b)
GPU Coder                                             Version 24.2        (R2024b)
Global Optimization Toolbox                           Version 24.2        (R2024b)
HDL Coder                                             Version 24.2        (R2024b)
HDL Verifier                                          Version 24.2        (R2024b)
Image Acquisition Toolbox                             Version 24.2        (R2024b)
Image Processing Toolbox                              Version 24.2        (R2024b)
Industrial Communication Toolbox                      Version 24.2        (R2024b)
Instrument Control Toolbox                            Version 24.2        (R2024b)
LTE Toolbox                                           Version 24.2        (R2024b)
Lidar Toolbox                                         Version 24.2        (R2024b)
MATLAB Coder                                          Version 24.2        (R2024b)
MATLAB Compiler                                       Version 24.2        (R2024b)
MATLAB Compiler SDK                                   Version 24.2        (R2024b)
MATLAB Report Generator                               Version 24.2        (R2024b)
MATLAB Test                                           Version 24.2        (R2024b)
Mapping Toolbox                                       Version 24.2        (R2024b)
Medical Imaging Toolbox                               Version 24.2        (R2024b)
Mixed-Signal Blockset                                 Version 24.2        (R2024b)
Model Predictive Control Toolbox                      Version 24.2        (R2024b)
Model-Based Calibration Toolbox                       Version 24.2        (R2024b)
Motor Control Blockset                                Version 24.2        (R2024b)
Navigation Toolbox                                    Version 24.2        (R2024b)
Optimization Toolbox                                  Version 24.2        (R2024b)
Parallel Computing Toolbox                            Version 24.2        (R2024b)
Partial Differential Equation Toolbox                 Version 24.2        (R2024b)
Phased Array System Toolbox                           Version 24.2        (R2024b)
Powertrain Blockset                                   Version 24.2        (R2024b)
Predictive Maintenance Toolbox                        Version 24.2        (R2024b)
RF Blockset                                           Version 24.2        (R2024b)
RF PCB Toolbox                                        Version 24.2        (R2024b)
RF Toolbox                                            Version 24.2        (R2024b)
ROS Toolbox                                           Version 24.2        (R2024b)
Radar Toolbox                                         Version 24.2        (R2024b)
Reinforcement Learning Toolbox                        Version 24.2        (R2024b)
Requirements Toolbox                                  Version 24.2        (R2024b)
Risk Management Toolbox                               Version 24.2        (R2024b)
Robotics System Toolbox                               Version 24.2        (R2024b)
Robust Control Toolbox                                Version 24.2        (R2024b)
Satellite Communications Toolbox                      Version 24.2        (R2024b)
Sensor Fusion and Tracking Toolbox                    Version 24.2        (R2024b)
SerDes Toolbox                                        Version 24.2        (R2024b)
Signal Integrity Toolbox                              Version 24.2        (R2024b)
Signal Processing Toolbox                             Version 24.2        (R2024b)
SimBiology                                            Version 24.2        (R2024b)
SimEvents                                             Version 24.2        (R2024b)
Simscape                                              Version 24.2        (R2024b)
Simscape Battery                                      Version 24.2        (R2024b)
Simscape Driveline                                    Version 24.2        (R2024b)
Simscape Electrical                                   Version 24.2        (R2024b)
Simscape Fluids                                       Version 24.2        (R2024b)
Simscape Multibody                                    Version 24.2        (R2024b)
Simulink 3D Animation                                 Version 24.2        (R2024b)
Simulink Check                                        Version 24.2        (R2024b)
Simulink Code Inspector                               Version 24.2        (R2024b)
Simulink Coder                                        Version 24.2        (R2024b)
Simulink Compiler                                     Version 24.2        (R2024b)
Simulink Control Design                               Version 24.2        (R2024b)
Simulink Coverage                                     Version 24.2        (R2024b)
Simulink Design Optimization                          Version 24.2        (R2024b)
Simulink Design Verifier                              Version 24.2        (R2024b)
Simulink Desktop Real-Time                            Version 24.2        (R2024b)
Simulink Fault Analyzer                               Version 24.2        (R2024b)
Simulink PLC Coder                                    Version 24.2        (R2024b)
Simulink Real-Time                                    Version 24.2        (R2024b)
Simulink Report Generator                             Version 24.2        (R2024b)
Simulink Test                                         Version 24.2        (R2024b)
SoC Blockset                                          Version 24.2        (R2024b)
Stateflow                                             Version 24.2        (R2024b)
Statistics and Machine Learning Toolbox               Version 24.2        (R2024b)
Symbolic Math Toolbox                                 Version 24.2        (R2024b)
System Composer                                       Version 24.2        (R2024b)
System Identification Toolbox                         Version 24.2        (R2024b)
Text Analytics Toolbox                                Version 24.2        (R2024b)
UAV Toolbox                                           Version 24.2        (R2024b)
Vehicle Dynamics Blockset                             Version 24.2        (R2024b)
Vehicle Network Toolbox                               Version 24.2        (R2024b)
Vision HDL Toolbox                                    Version 24.2        (R2024b)
WLAN Toolbox                                          Version 24.2        (R2024b)
Wavelet Toolbox                                       Version 24.2        (R2024b)
Wireless HDL Toolbox                                  Version 24.2        (R2024b)
Wireless Testbench                                    Version 24.2        (R2024b)

Let's take a look at a couple of simple examples.

Matlab example 1: Serial command line use

1. Load necessary modules:

module load matlab

This already lets you use Matlab directly in text mode on the login node:

[<NetID>@login03 ~]$ matlab
MATLAB is selecting SOFTWARE OPENGL rendering.

                                  < M A T L A B (R) >
                        Copyright 1984-2024 The MathWorks, Inc.
                    R2024b Update 4 (24.2.0.2833386) 64-bit (glnxa64)
                                   December 26, 2024


To get started, type doc.
For product information, visit www.mathworks.com.

>>

However, since we are working on a supercomputer, our goal is to make Matlab read and write data from/to files, all by itself. Let's learn how to do this!

2. Create an example script:

Here is the sine.m Matlab script, with which we will plot a sine function to a .png file:

x = -2*pi:0.01:2*pi;
y = sin(x);
h = figure('Visible','off');
plot(x,y);
print(h,'-dpng','mySineWave.png');
close(h);

3. Check if this works (interactively, on a login node):

matlab -batch "run('sine'); exit;"

This should generate the file called mySineWave.png:

mySineWave

4. Now, let's do the same properly, by submitting the job to the queue:

First, create a slurm script called matlab.sh:

#!/bin/sh
#
#SBATCH --job-name="matlab_demo"
#SBATCH --partition=compute
#SBATCH --time=00:10:00
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=3G
#SBATCH --account=research-<faculty>-<department>

module load matlab

srun matlab -batch "run('sine'); exit;"

Second, submit your job:

sbatch matlab.sh

This will submit the job to the queue, and will request 1 CPU per job. As a result, this will generate the slurm-XXX.out file and the mySineWave.png file.

Matlab example 2: Parallel execution on a single node

The following example (parEigenLocal.m) will use 4 (locally available) CPUs in parallel:

function [elapsedTime] =  test_for()
nworker = 4
myCluster = parcluster('local');
parpool(myCluster, nworker)
N = 1000;
A = zeros(N,1);
tic;
parfor i = 1 : N
    E = eig(rand(100))+i;
    A(i) = E(1);
end
elapsedTime = toc;
end

In order to submit this job, we use the following submission script. Please note, that we have to specify that the job is running on a single node with --nodes=1 and we have to request one extra CPU for the matlab wrapper script, e.g. if we want 4 "workers", we have to specify 5 CPUs with --ntasks==5 and --cpus-per-task=1. This means, that the maximum number of CPUs you can request is 48 and the maximum number of workers you can request is 47 for compute-p1 nodes and 64(63) for compute-p2 nodes, respectively.

#!/bin/bash

#SBATCH --job-name="pforTest"
#SBATCH --time=00:15:00
#SBATCH --nodes=1
#SBATCH --ntasks=5
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=3GB
#SBATCH --partition=compute
#SBATCH --account=research-<faculty>-<department>

module load matlab
matlab -r parEigenLocal

Slurm output file will look as follows:

                            < M A T L A B (R) >
                  Copyright 1984-2024 The MathWorks, Inc.
             R2024b Update 4 (24.2.0.2833386) 64-bit (glnxa64)
                             December 26, 2024


To get started, type doc.
For product information, visit www.mathworks.com.


nworker =

     4

Starting parallel pool (parpool) using the 'Processes' profile ...
Connected to parallel pool with 4 workers.

ans = 

 ProcessPool with properties: 

            Connected: true
           NumWorkers: 4
                 Busy: false
              Cluster: Processes (Local Cluster)
        AttachedFiles: {}
    AutoAddClientPath: true
            FileStore: [1x1 parallel.FileStore]
           ValueStore: [1x1 parallel.ValueStore]
          IdleTimeout: 30 minutes (30 minutes remaining)
          SpmdEnabled: true


ans =

    2.5160

Parallel pool using the 'Processes' profile is shutting down.

Matlab example 3: Parallel execution on multiple nodes

In order to run Matlab on more than one node, we have to rely on Matlab Parallel Server. What Parallel Server does, is submitting the job to the queue on your behalf, provided that the "Slurm profile" is configured properly. Then you do not need a slurm script (it will be generated automatically), but only need to specify the correct "Slurm profile" in the Matlab script itself, e.g. here for 2 nodes, using 2 CPUs per node:

function [elapsedTime] =  test_for()
nworker = 4
myCluster = parcluster('SlurmProfile1');
myCluster.SubmitArguments = '--job-name=matlab-parallel --time=00:05:00 --account=research-<faculty>-<department> --partition=compute --nodes=2 --ntasks-per-node=2 --cpus-per-task=1 --mem-per-cpu=3GB';
parpool(myCluster, nworker)
N = 1000;
A = zeros(N,1);
tic;
parfor i = 1 : N
    E = eig(rand(100))+i;
    A(i) = E(1);
end
elapsedTime = toc;
end

Of course, before executing such a script, you have to setup the Slurm profile parameters correctly. In the example above, we pass these parameters with the myCluster.SubmitArguments command:

myCluster.SubmitArguments = '--job-name=matlab-parallel --time=00:05:00 --account=research-<faculty>-<department> --partition=compute --nodes=2 --ntasks-per-node=2 --cpus-per-task=1 --mem-per-cpu=3GB';
To execute the script, we will need to load a special, ParCluster-enabled version of Matlab:

module load matlab/R2024b-ParServ 

Then, we execute the above script without GUI:

matlab -nodesktop -nosplash -r "parEigen,quit"

This should invoke Matlab:

                                       < M A T L A B (R) >
                             Copyright 1984-2024 The MathWorks, Inc.
                        R2024b Update 4 (24.2.0.2833386) 64-bit (glnxa64)
                                        December 26, 2024


To get started, type doc.
For product information, visit www.mathworks.com.


nworker =

     4

Starting parallel pool (parpool) using the 'SlurmProfile1' profile ...

and spawn a new job to the queue:

$ squeue --me
             JOBID PARTITION     NAME     USER ST       TIME  NODES NODELIST(REASON)
           7092221 compute-p matlab-p NetID R       0:01      2 cmp[091,cmp092]

Finally, the result then is:

nworker =

     4

Starting parallel pool (parpool) using the 'SlurmProfile1' profile ...
Connected to the parallel pool (number of workers: 4).

ans =

 ClusterPool with properties:

            Connected: true
           NumWorkers: 4
              Cluster: SlurmProfile1
        AttachedFiles: {}
    AutoAddClientPath: true
          IdleTimeout: 30 minutes (30 minutes remaining)
          SpmdEnabled: true
 EnvironmentVariables: {}


ans =

    1.4681
What to do if I don't have SlurmProfile1?
  1. Start Matlab's GUI via online portal OpenOndemand.

  2. Create and configure a new Slurm profile:

    1. Go to Parallel -> Parallel Preferences -> Cluster Profile Manager

    2. Create and/or edit the SlurmProfile1 profile

    3. Configure it with appropriate parameters (shouldn't really matter too much what you specify there, because you will pass all these parameters again with the myCluster.SubmitArguments = '...' keyword):

      matlab-slurm-profile-new

    When you close Matlab, these configuration files should be saved in your /home/$USER/.matlab folder and you should be able to submit jobs via script, as I described earlier.