This example assumes the user has a Research Computing account and is logged in to the Discovery high performance computing environment
Matlab ".m" files with HPC batch scripts (sbatch shell scripts)
sample ".m" file, test-m-file.m:
disp("show this text")
Pitch = [0.7;0.8;1;1.25;1.5];
Shape = {'Pan';'Round';'Button';'Pan';'Round'};
Price = [10.0;13.59;10.50;12.00;16.69];
Stock = [376;502;465;1091;562];
T = table(Pitch,Shape,Price,Stock)
writetable(T,'tabledata.txt');
sample batch file to submit the ".m" file above, sbatch_run_mfile.sh:
#!/bin/bash -l
# Request 1 CPU for the job
#SBATCH --cpus-per-task=1
# Request 8GB of memory for the job
#SBATCH --mem=8GB
# Walltime (job duration)
#SBATCH --time=00:05:00
# Then finally, our code we want to execute.
module load matlab
matlab -nodisplay -nodesktop -nosplash -nojvm -r "run test-m-file.m;quit"
Run the sbatch shell script:
$ sbatch batch_matlab_m4.sh
View file in queue:
$ squeue -u f002d69
JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)
3024150 standard batch_ma GaughanS R 0:02 1 q01
When the batch job finishes, view the batch file's ".out" file:
$ less slurm-3024090.out
View the data written to the output file:
$ less tabledata.txt
reference (Matlab support) https://www.mathworks.com/help/matlab/import_export/write-to-delimited-data-files.html