FAQ: MATLAB

1. How to start MATLAB

Matlab interface can be run on MobileVisLab or xterm window on Atlasx cluster open from HPC/SGD portal. Type ‘matlab’ at the command line prompt to start the Matlab interface. To quite Matlab at any time, enter ‘exit’ at the Matlab prompt.

# matlab &

2. How to run large and long CPU hours MATLAB jobs?

Matlab jobs that are large and need longer computing time to run can be submitted to batch queue(s) to run as batch mode. As Matlab is not a parallelised program by default, batch Matlab jobs shall be submitted to batch queue “serial” for best use computational resources. If you code with parallel Matlab toolbox, you can submit it as a parallel job to batch queue “parallel12”.

Alternatively, you can submit Matlab job in the system as below:

# matlab-job my_matlab_prog.m

If you use parallel Matlab toolbox for parallel computing, you can submit the job as:

# matlab-job my_matlab_prog.m  -parallel

where

  • “matlab-job” is a customized and automated job submission interface for Matlab program.
  • “my_matlab_prog.m” is the filename of your Matlab program to run.
  • “-parallel” is only needed if you code with Matlab parallel toolbox.

The Matlab program “my_matlab_prog.m” should define all the tasks you need to execute properly and completely, and MUST contain, as a last command, the “exit” command.

3. How many Matlab jobs can I submit and run?

You can submit multiple Matlab jobs to batch queue serial and large memory queue large. If your Matlab program calls specific Toolbox(es), it may depend on the available license for the toolbox(es).

4. How to run more Matlab jobs using Matlab Compiler RUNTIME (MCR)?

You can use the Matlab Compiler RUNTIME, or MCR, to compile your Matlab program into standalone executable files, then you can run the program independently without the need of the Matlab and its license.

Assume your main Matlab program is main2.m, you can compile it via:

# matlab-mcc -m main2.m

After the compilation is completed, it will generate two files in the current directory: main2 and run_main2.sh.

Now you can run the compiled executable via:

# matlab-run ./run_main2.sh

The execution takes a while (approximate one minute) in preparing the MCR environment. Once the program starts running, it will be executed seamlessly as it is in Matlab platform.

You can also submit the compiled program to run in batch queues. For example:

# matlab-job ./run_main2.sh -compiled

The flag “-compiled” is the keyword to indicate that you are submitting a compiled program. Without this, the job will fail.

5. How to run Matlab jobs in parallel?

You have to parallelize your Matlab codes first then you can run your Matlab program on multiple CPU cores to speed up the computation. Matlab provides a Parallel Computing Toolbox, where you can find out more details and some useful tutorials on how to parallelize Matlab codes. Please take note that not all Matlab codes can be parallelized. You need to study it and try it out.