nano simplefunction.m
and Copy and Paste the following (it makes a random matrix and displays the result of a calculation), write out and exit:
function simplefunction(n)
n = str2double(n);
a = rand(n);
save simpleMatlab a
2^10
nano simpleMatlab.sl
and Copy and Paste the following (you need to replace projectIDhere
with your project ID from OtagoPanInstructions), write out and exit:
#!/bin/bash
#SBATCH -J yourjobName
#SBATCH -A projectIDhere
#SBATCH --time=1:00:00
#SBATCH --mem-per-cpu=2048
#SBATCH --output=simpleMatlabout.txt
#SBATCH --error=simpleMatlaberr.txt
module load MATLAB/2015b
srun matlab -nodesktop -nosplash -nodisplay -nojvm -r 'simplefunction 20'
sbatch simpleMatlab.sl
.
simpleMatlab.mat
: a MATLAB file with a 20 by 20 random matrix in it
simpleMatlabout.txt
: including the text "1024" from calculating 2^10
simpleMatlaberr.txt
: empty file
simpleMatlab.mat
to your local machine (see OtagoPanInstructions) or look at it on the build node using:
ssh build-sb
module load MATLAB/2015b
matlab
load simpleMatlab
disp(a)
str2double
(as we did in step 2 above).
#SBATCH --output=
) or (much more likely) save results, e.g. to a .mat
file (as we did in step 1).
.sl
script (change the 8 to the number of CPUs your code can use):
#SBATCH --cpus-per-task=8
#SBATCH --ntasks=1