MATLAB
Licences
The MATLAB installation on ALICE is the same as that on University PCs and shares the campus licence. The versions currently available are 2011b and 2013a.
There are 200 licences for the core MATLAB application and a smaller number for a selection of toolboxes. The table below shows which toolboxes are are available and the number of licences we have for each.
| Component | Licences |
Resource Name |
|---|---|---|
| MATLAB | 200 |
MATLAB |
| Communication Toolbox |
10 |
Communication_Toolbox |
| Control Toolbox |
52 |
Control_Toolbox |
| Econometrics Toolbox |
2 |
Econometrics_Toolbox |
| Financial Toolbox |
2 |
Financial_Toolbox |
| Fuzzy Logic Toolbox |
1 |
Fuzzy_Toolbox |
| Neural Network Toolbox |
1 |
Neural_Network_Toolbox |
| Optimization Toolbox |
2 |
Optimization_Toolbox |
| SimPowerSystems |
10 |
Power_System_Blocks |
| Robust Control Toolbox |
3 |
Robust_Toolbox |
| Simscape |
10 |
Simscape |
| Simulink |
50 |
SIMULINK |
| Simulink Control Design |
50 |
Simulink_Control_Design |
| Signal Processing Blockset |
10 |
Signal_Blocks |
| Signal Processing Toolbox |
11 |
Signal_Toolbox |
| Statistics Toolbox |
4 |
Statistics_Toolbox |
| Symbolic Maths Toolbox |
2 |
Symbolic_Toolbox |
| Wavelet Toolbox |
1 |
Wavelet_Toolbox |
| NAG MATLAB Toolbox* |
Unlimited |
*NAG MATLAB Toolbox is currently not available for MATLAB 2011b.
Submit a MATLAB Job
To submit a MATLAB job, you need to submita MATLAB function file (a .m file) to the scheduler.
The example submission script below requests 10 hours of walltime and executes a MATLAB function script called mscript.m located in the same directory as the submission script. In this example the MATLAB script uses the functions in the Signal Processing Toolbox, so you need to tell the scheduler that the job cannot run until there is a licence for both MATLAB and the Signal Processing Tool.
#!/bin/bash # #PBS -N MATLAB_job #PBS -l nodes=1:ppn=1 #PBS -l vmem=4g #PBS -l walltime=10:00:00 module load matlab/2011b cd $PBS_O_WORKDIR matlab -nodisplay -nojvm -r mscript
- Start MATLAB with the -r option
- Specify the name of the MATLAB program without the .m suffix
- Use the -nodisplay option to stop MATLAB from starting its user interface or opening any display windows. It's important that the MATLAB program doesn't attempt to open any windows itself during execution since this will fail.
The resource names to request for MATLAB toolboxes are listed in the third column of the table above.
If you specify the required licences in the submission script then the MATLAB job won't start if licences are unavailable. However a Toolbox licence isn't checked out until one of its functions is called. A long-running MATLAB program may not use a function from a requested Toolbox for some time and they may all be checked out by the time it does. Therefore you should check for licence availability of required toolboxes within the MATLAB program and act accordingly if the licence is not available. See this page for a method of checking for licence availability from within a MATLAB program.
Parallel MATLAB Jobs
Some of MATLAB's functions will automatically take advantage of multiple cores under some circumstances. When a job submission script specifies nodes=1:ppn=N where N > 1, MATLAB will use N threads where possible. There's no gain in doing this if your code doesn't fit the criteria for taking advantage of multiple cores though - please read Which MATLAB Functions Benefit from Multithreaded Computation? for details.
Passing Arguments to MATLAB Programs
It is easy to pass arguments from a job submission script to a MATLAB program. This can be used as a basis for creating MATLAB array jobs and automating parameter sweeps etc.
In the job submission script at the line where MATLAB is called, you can pass an argument with a value as part of the MATLAB program name. For example to set the MATLAB variable x to the value 4 on initialisation of the program mscript.m, use the following:
matlab -nodesktop -nojvm -r "x=4;mscript"
When mscript.m starts, x will have the value 4.
You can pass multiple arguments by separating them with semi-colons:
matlab -nodesktop -nojvm -r "x=4;y=5;mscript"