First, define the paths:
export LD_LIBRARY_PATH=/opt/matlab2012a/bin/glnxa64:/opt/matlab2012a/sys/os/glnxa64:/opt/matlab2012a/runtime/glnxa64/
Compile the .m file
mcc -mv mymatlabfile.m
The matlab compiler generates two execute files: mymatlabfile and run_mymatlabfile.sh
Ignore the shell script generated by matlab. Simply execute ./mymatlabfile
If you have addpath commands in your .m file, these will cause error while running the standalone executables. To solve this, do the following
if ~isdeployed addpath('path1...'); end
If your .m file has input parameters, execute the file in the following way
mymatlabfile para1 para2.
For example, if this is your matlab file
function myprog(num1, num2)
you call the file by
myprog 100 200
Note that the paramters 100 and 200 will be passed as string instead of numbers so you have to modify your .m file:
function myprog(num1, num2) if isdeployed num1 = str2double(num1); num2 = str2double(num2); end
Bash script to run in clusters
#!/bin/bash # total number = 8677 for i in {1..8599..860} do let j=$i+860-1 echo "Running $i and $j....." srun -c 5 -o output/output$i.txt ./calc_bg_pooling $i $j & done echo "Running the last small part....." srun -c 5 -o output/output8601.txt ./calc_bg_pooling 8601 8677 &