MATLAB is a technical computing environment for high-performance numeric computation and visualization. MATLAB integrates numerical analysis, matrix computation, signal processing, and graphics in an easy-to-use envionment where problems and solutions are expressed just as they are written mathematically--without traditional programming.
Different versions of MATLAB are available on the various OSC clusters.
* - Default version
MATLAB is available on the Glenn Cluster and the Oakley Cluster. All Ohio State users must be added to the license server before using MATLAB. Please contact OSC Help to be granted access.
OSC cannot provide MATLAB licenses for academic use to students and faculty outside of Ohio State at this time. However, if you have your own MATLAB license, including the Parallel Computing Toolbox, you will be able to connect to the MATLAB Distributed Computing Server on Oakley via your MATLAB interface. See HOW-TO: Configure the MATLAB Parallel Computing Toolbox.
Use of MATLAB requires validation. See the Software Form page for the software agreement form for MATLAB for non-OSC users.
To load the default version of MATLAB into your environment, you can use the following command.
module load matlab
To load a specific version of MATLAB on your current system, you can use variations of the previous command. The command format expected by each system differs slightly, thus the invocation of a particular version of MATLAB depends on the system you wish to run on.
For example, if you’d like to load MATLAB 2012a on Glenn, type:
module load matlabR2012a
If you’d like to load MATLAB 2012a on Oakley, type:
module load matlab/R2012a
For a list of available MATLAB versions and the format expected on Glenn, type:
module avail matlab
For a list of all available MATLAB versions and the format expected on Oakley, type:
module spider matlab
The following command will start an interactive, command line version of MATLAB on either cluster system:
If you are able to use X-11 forwarding and have enabled it in your SSH client software preferences, you can run MATLAB using the GUI by typing the command “
For more information about the matlab command usage, type “
matlab –h” for a complete list of command line options.
The commands listed above will run MATLAB on the login node you are connected to. As the login node is a shared resource, running scripts that require significant computational resources will impact the usability of the cluster for others. As such, you should not use interactive MATLAB sessions on the login node for any significant computation. If your MATLAB script requires significant time, CPU power, or memory, you should run your code via the batch system.
MATLAB should be run via the batch system for any scripts that are computationally intensive, long running, or memory intensive.
To run an interactive batch job using the command line version of MATLAB, you can use the following command:
qsub –I –X –l nodes=n:ppn=p –l walltime=hh:mm:ss
After submitting your job, you will be logged on to one of the compute nodes. Here you can run MATLAB interactively by loading the MATLAB module and running MATLAB with the options of your choice as described above. The
–X flag enables X-11 forwarding on the compute node, so you can use the MATLAB GUI if you choose.
In order to run MATLAB non-interactively via the batch system, you will require a batch submission script and a MATLAB M-file containing the script that will be run via the batch system. You can create both of these files using any text editor you like in a working directory on the system of your choice.
Below is an example batch submission script and a simple M-file. The batch script runs the M-file via the batch system.
Example batch submission script,
#PBS -N matlab_example #PBS -l walltime=00:10:00 #PBS -l nodes=1:ppn=8 #PBS -j oe
module load matlab matlab -nodisplay -r hello # end of example file
Example M-file, hello.m:
%Example M-file for Hello World
disp 'Hello World' exit % end of example file
In order to run hello.m via the batch system, submit the
script.job file with the following command:
This will run
hello.m via the batch system, and all output from the running of the script will be saved in the
For more information about using the batch system, see Batch Processing at OSC.
To view a complete list of the currently available toolboxes, in the MATLAB command line type the command "
MATLAB supports both implicit multiprocessing (multithreading) and explicit multiprocessing across multiple nodes.
Multithreading allows some functions in MATLAB to distribute the work load between cores of the node that your job is running on. By default, all of the current versions of MATLAB available on the OSC clusters have multithreading enabled.
The use of multithreading differs slightly depending on which cluster you'd like to run your jobs on. On Oakley, the system will use a number of threads equal to the number of cores you request. Therefore, if you request nodes=1:ppn=4, your job will only spawn four threads. However, on the Glenn cluster the system will use a number of threads equal to the number of cores on one node. You must, therefore, request nodes=1:ppn=8 otherwise your jobs may be killed.
Multithreading increases the speed of some linear algebra routines, but if you would like to disable multithreading you may request nodes=1:ppn=1 and include the option "
-singleCompThread" when running MATLAB.
#PBS -N disable_multithreading #PBS -l walltime=00:10:00 #PBS -l nodes=1:ppn=1 #PBS -j oe module load matlab matlab -singleCompThread -nodisplay -r hello # end of example file
You can accomplish parallel processing using multiple nodes by using the Parallel Computing Toolbox in conjunction with the MATLAB Distributed Computing Server. For more information about configuration and usage, see HOW-TO: Configure the MATLAB Parallel Computing Toolbox.
Official PDF documentation can be obtained from the MathWorks website.