The CSF2 has been replaced by the CSF3 - please use that system! This documentation may be out of date. Please read the CSF3 documentation instead. To display this old CSF2 page click here. |
MATLAB
Overview
MATLAB [MATrix LABoratory] is an integrated technical computing environment from The Mathworks that combines numeric computation, 2- and 3-d graphics & visualisation, and a high-level programming language.
Version 2017a is the most up to date version installed on the CSF.
Restrictions on use
Only compiled MATLAB applications should be used on the CSF; interactive use of MATLAB is strongly discouraged. The only MATLAB components you should run on the login node are the mcc
and mex compilers.
Please note that a MATLAB job cannot run on more than one CSF node. This is because the University does not have licenses for the distributed computing server product. The maximum job size is therefore 12 cores. Please get in touch if you would like help assessing the requirements of your job.
Set up procedure
To set up the MATLAB environment, you need to issue the following command
module load apps/binapps/matlab/R2017a
Change in behaviour
gcc version 4.9.x is requried for MATLAB 2017a: loading the MATLAB module (e.g. by using the command above) will automatically load this for you.
gcc version 4.7.x is required for MATLAB 2016a, 2015a and 2014a; loading the MATLAB module (e.g. by using the command above) will automatically load this for you.
Older versions of MATLAB are available using one of:
module load apps/binapps/matlab/R2016a module load apps/binapps/matlab/R2015a module load apps/binapps/matlab/R2014a module load apps/binapps/matlab/R2013a module load apps/binapps/matlab/R2012a module load apps/binapps/matlab/R2011a module load apps/binapps/matlab/R2010a
Running the application
You must compile your MATLAB code before running it on the CSF in the batch system.
- Fundamentals – How to compile and submit a very simple MATLAB example on the CSF.
- MATLAB Compilation advice – further advice for MATLAB on the CSF.
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
The following toolboxes are available in MATLAB R2016a and R2015a
- Bioinformatics Toolbox
- Control System Toolbox
- Embedded Coder
- Financial Toolbox
- Fuzzy Logic Toolbox
- Global Optimization Toolbox
- Image Processing Toolbox
- MATLAB
- MATLAB Coder
- MATLAB Compiler
- Neural Network Toolbox
- OPC Toolbox
- Optimization Toolbox
- Parallel Computing Toolbox
- Partial Differential Equation Toolbox
- Robust Control Toolbox
- Signal Processing Toolbox
- Simulink
- Simulink 3D Animation
- Simulink Coder
- Simulink Control Design
- Statistics and Machine Learning Toolbox
- Symbolic Math Toolbox
- System Identification Toolbox
- Wavelet Toolbox
The following toolboxes are available in MATLAB 2014a
- MATLAB
- Simulink
- Bioinformatics Toolbox
- Control System Toolbox
- Financial Toolbox
- Fuzzy Logic Toolbox
- Global Optimisation Toolbox
- Image Processing Toolbox
- MATLAB Coder
- MATLAB Compiler
- Neural Networks
- Optimization Toolbox
- Parallel Computing Toolbox
- PDE Toolbox
- Robust Control Toolbox
- Signal Processing Toolbox
- Simulink 3D Animation
- Simulink Coder
- Simulink Control Design
- Statistics Toolbox
- Symbolic Math
- System ID
- Wavelets
The following toolboxes are available in MATLAB 2013a and below
- MATLAB
- Simulink
- Bioinformatics Toolbox
- Control System Toolbox
- Fuzzy Logic Toolbox
- Global Optimization Toolbox
- Image Processing Toolbox
- MATLAB Coder
- MATLAB Compiler
- Neural Network Toolbox
- Optimization Toolbox
- Parallel Computing Toolbox
- Robust Control Toolbox
- Signal Processing Toolbox
- Statistics Toolbox
- Symbolic Math Toolbox
- System Identidication Toolbox
- Wavelet Toolbox
Please note that some of these toolboxes have extremely limited numbers of licenses. For example, there are only two licenses for the Bioinformatics toolbox site-wide.
If you can’t access one of the above toolboxes, or if you need to use a toolbox that isn’t included here, please read the advice given at the following URL. It gives advice on how to use alternatives to toolboxes along with contact details of IS Staff who can facilitate the purchase of extra toolboxes.
Additional Toolboxes
The following are available:
CVX
module load apps/binapps/matlab/thirdparty/cvx/2.1
YALMIP
module load apps/binapps/matlab/thirdparty/yalmip/R20160930
SDETools
module load apps/binapps/matlab/thirdparty/sdetools/1.2
SPM
Version 12 latest:
module load apps/binapps/matlab/thirdparty/spm/12-latest # # !!! Note this will always point to the most recent version we have added # If you need a specific version or do not want anything to unexpectedly change # please ensure you use a specific modulefile from those below
Version 12 revision 6906: module load apps/binapps/matlab/thirdparty/spm/12-r6906
Version 12 revision 5953: module load apps/binapps/matlab/thirdparty/spm/12b
Compilation (basic usage)
After loading the SPM module file, the SPM toolbox should be compiled as follows:
# Create a directory in your scratch area and use that directory name in all commands. # This is easy to do if we set an environment variable: export SPM12_STANDALONE=~/scratch/SPM12-standalone mkdir -p $SPM12_STANDALONE # Now compile the spm12 wrapper script in to our directory: mcc -m -C -v -o spm12 -d $SPM12_STANDALONE -N -p $MATLAB_HOME/toolbox/signal/ -R singleCompThread \ -a $SPM12_ROOT $SPM12_ROOT/spm_standalone.m
Compilation (including your own toolbox code)
If you need to use code from your own toolbox, you will need to modify the compilation command above to include your toolbox folder using the -a
flag as follows:
# Create a directory in your scratch area and use that directory name in all commands. # This is easy to do if we set an environment variable: export SPM12_STANDALONE=~/scratch/SPM12-standalone mkdir -p $SPM12_STANDALONE mcc -m -C -v -o spm12 -d $SPM12_STANDALONE -N -p $MATLAB_HOME/toolbox/signal -R singleCompThread \ -a $SPM12_ROOT -a path/to/yourtoolbox $SPM12_ROOT/spm_standalone.m
Submitting a job
After compilation, change directory to your SPM12 standalone directory so that our jobscript can find the files we compiled above:
cd $SPM12_STANDALONE
Then use this line in your job script (instead of the usual matlab commands):
./run_spm12.sh $MATLAB_HOME script yourscript.m # Replace yourscript.m with the name of your script
The compiled spm12 code will run the matlab code you have written in yourscript.m but this is still essentially a compiled matlab job so will be kind to the license servers.
Marsbar and fieldtrip
/opt/gridware/apps/binapps/matlab/third_party_toolboxes/marsbar
/opt/gridware/apps/binapps/matlab/third_party_toolboxes/fieldtrip
You should set your MATLABPATH
appropriately to use them.
NAG
module load apps/binapps/matlab/thirdparty/nag/25
Further information
- Community Wiki page on MATLAB
- 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