Matlab can be loaded with the
module command, as in,
$ module load matlab
which will load the default version of the
matlab module. To see which versions of Matlab are installed, use
$ module keyword matlab
matlab module is loaded, the
matlab command will be available.
Running your Matlab program from a Slurm batch script (
.sbat) is usually done with a line like this, where your Matlab program is in
my_program.m in the current directory.
matlab -nodisplay -r "my_program ; exit"
-r option instructs
matlab to run the command(s) that follow. The example above shows how to run more than one command, with the
; as the
matlab command terminator. You could use
-r my_program without the
exit, however, if your Matlab script does not contain the
exit command, then Matlab will complete
my_program.m and wait for input until your job runs out of time and is terminated.
You do NOT want that to happen; you will be paying for that wait time, and if Matlab does not exit properly, it may leave files around that will interfere with future sessions.