MATLAB (matrix laboratory) is a multi-paradigm numerical computing environment and proprietary programming language developed by MathWorks. MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages. Although MATLAB is intended primarily for numerical computing, an optional toolbox uses the MuPAD symbolic engine allowing access to symbolic computing abilities. An additional package, Simulink, adds graphical multi-domain simulation and model-based design for dynamic and embedded systems.
Sample Batch Script to run MATLAB: matlab_parallel.sh
1 2 3 4 5 6 7 8 910111213141516171819
#!/bin/bash#SBATCH -J test_matlab#SBATCH --output=%x.%j.out # %x.%j expands to slurm JobName.JobID#SBATCH --error=%x.%j.err # prints the error message#SBATCH --partition=general#SBATCH --nodes=1#SBATCH --ntasks-per-node=32#SBATCH --mem-per-cpu=4000M # Maximum allowable mempry per CPU 4G#SBATCH --qos=standard#SBATCH --account=PI_ucid # Replace PI_ucid which the NJIT UCID of PI#SBATCH --time=71:59:59 # D-HH:MM:SS# Load matlab modulemodulepurge
moduleloadwulver# Load the slurm, easybuildmoduleloadMATLAB
# Run matlabmatlab-nodisplay-nosplash-r'cd('/path/to/for_loop.m');for_loop; quit'
Replace cd('/path/to/for_loop.m') with the actual path of the matlab script. You don't need to use cd('/path/to/for_loop.m') if the Matlab script and job script are in the same directory. In that case, use matlab -nodisplay -nosplash -r 'for_loop; quit'
Sample Parallel MATLAB script: for_loop.m
1 2 3 4 5 6 7 8 91011
poolobj=parpool('local',32);fprintf('Number of workers: %g\n',poolobj.NumWorkers);ticn=2000;A=500;a=zeros(n);parfori=1:na(i)=max(abs(eig(rand(A))));endtoc