MATLAB
Overview
MATLAB is an integrated technical computing environment from The MathWorks for Maths, Programming and Graphics.
Version R2022a is installed on CSF4.
Restrictions on use
October 2023: We have removed the requirement to compile your MATLAB code!
Compilation is no longer needed now that the University has a larger pool of MATLAB licenses. Previously, compilation was used to check-out a license only at compile time, not runtime. Given that the CSF is often used for large job-arrays (10,000s of tasks) running MATLAB, it used to be possible to use up all of the campus licenses. Now that there are more licenses, we won’t run out. So you can run un-compiled MATLAB jobs and each one will safely get a license.
An advantage of NOT compiling your code is that you may now run code that uses the Signal Processing Toolkit. It is NOT possible to compile SPT code, but you can now run this un-compiled on the CSF.
You may still compile your MATLAB code if you wish to. It will not improve the performance of your code. One benefit would be if the University license servers were suddenly unavailable – a batch job using compiled MATLAB would be able to start without problems because it doesn’t need to check-out a license.
Other restrictions and advice remain:
- Interactive use of the MATLAB GUI is strongly discouraged (remote use of the GUI is slow).
- The only MATLAB components you should run on the login node are the
mcc
andmex
compilers to compile your .m files. All MATLAB jobs, whether compiled or not, MUST be submitted to the batch system. - MATLAB parallel jobs cannot run across more than one CSF compute node. This is because the University does not have licenses for the Distributed Computing Server product. The maximum job size on CSF4 is therefore 40 cores. Please get in touch if you would like help assessing the requirements of your job.
Set up procedure
We recommend that you load the MATLAB modulefile in your jobscript.
If you wish to compile your matlab code (it is no longer mandatory) you should also load the modulefile at the login node command-line.
Load one of the following modulefiles:
module load matlab/R2022a
Running the application
Un-compiled MATLAB uses a slightly different command in your jobscript compared to compiled MATLAB. Please see
If you still wish to compile your MATLAB code (which is now optional), our instructions from the CSF3 are still available:
- Basics of Compiling MATLAB Code – How to compile and submit a very simple MATLAB example on CSF3 and also how to make job-arrays work with MATLAB. You will need to modify the jobscripts mentioned in those notes to run on CSF4. See the CSF4 SGE to SLURM docs for more information about converting CSF3 jobscripts.
- More advanced usage is given in: More MATLAB Compilation hints and tips – further advice for MATLAB on CSF3.
NOTE: If you are running an application that uses random numbers, it is suggested that you read and understand the article Parallel Random Numbers in MATLAB
Official Toolboxes
To check which toolboxes are installed for a given version of MATLAB you can execute the following from a login node:
matlab -nojvm -batch ver
Further information
- It is often possible to speed-up MATLAB code significantly using techniques such as vectorisation, mex files, parallelisation and more. If you would like advice on how to optimise your MATLAB application then contact the Research IT applications team