Skip to content

Instructions for using Matlab software

Matlab is programming platform for analysing and designing systems, primary for numeric computing. Supports matrix manipulations, data plotting, implementation of algorithms, development of user interfaces, etc. Programs written in Matlab, can use libraries written in C, C++, Java and Fortran. Developed by MathWorks, read more

License

Matlab is a licensed software, HPC Vega offers Standard Concurrent license, which is intended to be used by multiple users simultaneously.

  • MATLAB Distrib Comp Engine (Total of 400 licenses issued)
  • MATLAB (Total of 1 license issued)
  • MATLAB Distrib Computing Toolbox (Total of 1 license issued)

Read more about our concurrent license at link.

To use Matlab on HPC Vega, users have to bring their own license. For more information ask support@sling.si.

Installation

Export environment variable for license file

export MLM_LICENSE_FILE=/path/to/file/license.dat
export MLM_LICENSE_FILE=27000@server1,27000@server2,27000@server3

Matlab version R2022a is available on HPC Vega, through module.

module load matlab

Matlab user interfaces

For the graphical user interface (GUI), X11 forwarding must be enabled on the client site, otherwise an interactive command line session will begin. The easiest way to check this is echo $DISPLAY, if value is not specified, the forwarding does not work.

Graphical user interface (GUI)

matlab -display Xdisplay

Command line interface (CLI)

matlab -nodisplay 

For additional information about Matlab commands, load module from your shell and check the help section.

matlab -h

Example of a Slurm task

The following example shows a task that will be run on 2 nodes and 12 cores. The job requires 2 GB RAM per core and will be carried out for 5 minutes on cpu partition.

Content of inputfile matlabtest.m:

function helloworld
   disp('Hello World!')
end

Content of SBATCH script:

#!/bin/bash

#SBATCH --job-name=matlab-test
#SBATCH --time=00:05:00
#SBATCH --partition=cpu
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=1
#SBATCH --cpus-per-task=12

module load matlab/matlab-R2022a

matlab -nodisplay -r matlabscript

Input file, e.g. shell or sbatch script must be exclude .m, output will be written inside slurm-<jobid>.log.

Example of sending with ARC

Firstly you will need ARC Client and a .xrsl file in which you state which resources you need to start the job, and contains two additional input files.

&
(count = 12)
(countpernode = 2)
(jobname = matlab-test)
(inputfiles = 
  ("matlabscript.sh" "")
  ("matlabscript.m" "")
)
(executable = matlabscript.sh)
(outputfiles = ("example.out" ""))
(stdout=example.log)
(join=yes)
(gmlog=log)
(memory=2000)
(walltime="5 minutes")

Example of matlabscript.sh:

#!/bin/bash

#Setup environment
. /ceph/hpc/software/cvmfs_env.sh

#Load module
module --ignore-cache load matlab

#Execute script
matlab -nodisplay -r matlabscript

For input script examples e.g. matlabscript.m, check the official documentation.

Documentation