Matlab
Access
The college has a site license for Matlab.
Running Matlab Interactively
There are a number of versions of Matlab installed on the TCHPC clusters.
To run Matlab interactively on the TCHPC clusters, you must:
- log in via SSH
- obtain an interactive allocation on the cluster, using your project code
- load the modules:
- To load the main version of matlab, currently version R2011b, type
module load apps matlab/R2011b - To load the version of matlab available to TCIN users, type
module load tcin matlab
- To load the main version of matlab, currently version R2011b, type
- and then run it from the command-line:
matlab
Running Matlab through the Batch System
To submit a batch Matlab job on the TCHPC clusters, you must:
- create a text file containing the commands you wish to run, e.g. "
test.m" (see below for an example) - the
.mmatlab file must includeexitas the last line, to make sure that matlab exits correctly - create a SLURM batch submission script (see below for an example)
- submit it to the queue
- when the job has finished, check the output
Sample Matlab File
This file (called "test.m") simply creates a matrix and prints it out.
% comments in the matlab file start with a percent sign % create the matrix A = rand(4,4); % print it out A % NB: include this line at the end exit;
Sample SLURM Script
This loads the relevant modules, calls Matlab with the given instructions, and redirects the output to a file called "output.txt".
#!/bin/bash #SBATCH -n 1 # number of cores #SBATCH -p compute # compute queue #SBATCH -t 00:10:00 # time (ddd-hh:mm:ss) #SBATCH -J matlab # job name #SBATCH -U HPC_11_00555 # the account string # load up the correct modules . /etc/profile.d/modules.sh module load tcin matlab # call matlab non-interactively matlab -nodisplay < test.m > output.txt
Alternatives to Matlab
There are a few free and open-source alternatives to Matlab such asScilab and Octave. These programs are available on a selection of the machines that TCHPC maintain.