User Tools

Site Tools


matlab

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

matlab [2017/11/02 21:08] (current)
jokinsey Created the Matlab documentation
Line 1: Line 1:
 +====Matlab====
 +
 +MATLAB (MATrix LABoratory) and is a numerical computing environment. You can find more information on the origins of Matlab [[https://​www.mathworks.com/​company/​newsletters/​articles/​the-origins-of-matlab.html|here]].
 +
 +====Enviornment Setup====
 +
 +To use matlab for the batch job we will demonstrate we need to load the required module. You can do this by modifying your ''​$HOME/​.bashrc''​ file to include the current Matlab module.
 +
 +<​code>​
 +module load matlab/​r2017a
 +</​code>​
 +
 +In your ''​$HOME''​ directory create another directory to run the Matlab jobs, and add the example job from Matlab that we will modify.
 +
 +<​code>​
 +razor-l1:​jokinsey:​~$ mkdir MATLAB-JOBS
 +razor-l1:​jokinsey:​~$ cp /​share/​apps/​matlab/​R2017a/​examples/​matlab_featured/​MultiplePlotsExample.m MATLAB-JOBS/​
 +</​code>​
 +
 +====Example Batch Job====
 +
 +To get output an output from the job we need to modify the example. At the top of the file where figure is defined set figure equal to a value so we can save it to a file later.
 +
 +<​code>​
 +f = figure;
 +</​code>​
 +
 +At any point after a plot is created you can save the figure to a pdf file ''​test''​ which will export the figure so we can view it later. You can find documentation on this [[https://​www.mathworks.com/​help/​matlab/​ref/​saveas.html|here]].
 +
 +<​code>​
 +saveas(f,'​test','​pdf'​);​
 +</​code>​
 +
 +Once the example has been prepared, create a ''​PBS''​ script named ''​matlabTest.pbs''​ which looks like the script below to run the job.
 +
 +<​code>​
 +#!/bin/bash
 +#PBS -N matlab
 +#PBS -q tiny12core
 +#PBS -j oe
 +#PBS -o matlab.$PBS_JOBID
 +#PBS -l nodes=1:​ppn=12
 +#PBS -l walltime=1:​00:​00
 +
 +cd $PBS_O_WORKDIR
 +cp MultiplePlotsExample.m /​scratch/​$PBS_JOBID
 +cd /​scratch/​$PBS_JOBID
 +
 +matlab -nodesktop -nosplash < MultiplePlotsExample.m
 +cp /​scratch/​$PBS_JOBID/​test.pdf $PBS_O_WORKDIR
 +</​code>​
 +
 +All that's left to do is submit the job.
 +
 +<​code>​
 +razor-l1:​jokinsey:​~/​MATLAB-JOBS$ qsub matlab.pbs
 +</​code>​
 +
  
matlab.txt · Last modified: 2017/11/02 21:08 by jokinsey