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 environment where problems and solutions are expressed just as they are written mathematically--without traditional programming.

## Availability and Restrictions

MATLAB is available on Ruby, Oakley, and Glenn Clusters. The versions currently available at OSC are:

Version | Glenn | Oakley | Ruby | notes |
---|---|---|---|---|

2010a | X | |||

2011a | X | |||

2011b | X | |||

2012a | X* | |||

2012b | ||||

2013a | X | Default version on Oakley prior to 09/15/2015 | ||

2013b | X | |||

2014a | X | X | Default version on Ruby prior to 09/15/2015 | |

2014b | X* | X* | ||

2015a | X | X | ||

2015b | X | X |

You can use `module avail matlab `

to view available modules for a given machine. Feel free to contact OSC Help if you need other versions for your work.

### Access to Ohio State University Students/Faculty

All Ohio State users must be added to the license server before using MATLAB. Please contact OSC Help to be granted access.

### Access to Non Ohio State University Students/Faculty

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; please contact OSC Help for further instruction.

## Usage

### Usage on Glenn

#### Set-up on Glenn

`module load matlab`

. To select a particular software version, use `module load matlabversion`

. For example, use `module load matlab2012a`

to load MATLAB version 2012a on Glenn. #### Running MATLAB

The following command will start an interactive, command line version of MATLAB on either cluster system:

matlab -nodisplayIf 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 “

`matlab`

”. 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.

#### Batch Usage on Glenn

When you log into glenn.osc.edu you are actually logged into a Linux box referred to as the login node. To gain access to the multiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request multiple nodes/cores and compute time, up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info. Batch jobs run on the compute nodes of the system and not on the login node. It is desirable for big problems since more resources can be used. MATLAB should be run via the batch system for any scripts that are computationally intensive, long running, or memory intensive.

##### Interactive Batch Session

For an interactive batch session using the command line version of MATLAB, one can run the following command:

qsub -I -X -l nodes=1:ppn=8 -l walltime=00:20:00

which requests one whole node with 8 cores ( `-l nodes=1:ppn=8`

), for a walltime of 20 minutes ( `-l walltime=00:20:00`

). 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 X11 forwarding on the compute node, so you can use the MATLAB GUI if you choose.You may adjust the numbers per your need.

##### Non-interactive Batch Job (Serial Run)

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. A batch script can be created and submitted for a serial or parallel run. You can create the batch script 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 script ( `job.txt`

) for a serial run:

#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 fileIn order to run

`hello.m`

via the batch system, submit the `job.txt`

file with the following command:
qsub job.txtThis will run

`hello.m`

via the batch system, and all output from the running of the script will be saved in the `output.txt`

file.#### Toolboxes

To view a complete list of the currently INSTALLED toolboxes, in the MATLAB command line type the command `ver`

. OSC's current licenses support the following toolboxes (please contact oschelp@osc.edu for license-specific questions):

```
Bioinformatics_Toolbox
Communication_Toolbox
Control_Toolbox
Curve_Fitting_Toolbox
Data_Acq_Toolbox
Fuzzy_Toolbox
Image_Toolbox
Instr_Control_Toolbox
Neural_Network_Toolbox
Optimization_Toolbox
Distrib_Computing_Toolbox
PDE_Toolbox
RF_Toolbox
Robust_Toolbox
Signal_Toolbox
Statistics_Toolbox
Symbolic_Toolbox
Identification_Toolbox
Wavelet_Toolbox
```

#### Parallel Processing in MATLAB

##### Multithreading

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 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. An example is given below:

#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

##### Parallel computing across multiple nodes

Parallel computing across multiple nodes is only available on Oakley.

### Usage on Oakley

#### Set-up on Oakley

`module load matlab`

. For a list of all available MATLAB versions and the format expected on Oakley, type: `module spider matlab`

. To select a particular software version, use `module load matlab/version`

. For example, use `module load matlab/r2014b`

to load MATLAB version 2014b on Oakley. #### Running MATLAB

The following command will start an interactive, command line version of MATLAB on either cluster system:

matlab -nodisplayIf 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

`matlab`

. 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.

#### Batch Usage on Oakley

When you log into oakley.osc.edu you are actually logged into a Linux box referred to as the login node. To gain access to the multiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request multiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info. Batch jobs run on the compute nodes of the system and not on the login node. It is desirable for big problems since more resources can be used.

##### Interactive Batch Session

For an interactive batch session using the command line version of MATLAB, one can run the following command:qsub -I -X -l nodes=1:ppn=12 -l walltime=00:20:00

which requests one whole node with 12 cores ( `-l nodes=1:ppn=12`

), for a walltime of 20 minutes ( `-l walltime=00:20:00`

). 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 X11 forwarding on the compute node, so you can use the MATLAB GUI if you choose.You may adjust the numbers per your need.

##### Non-interactive Batch Job (Serial Run)

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. A batch script can be created and submitted for a serial or parallel run. You can create the batch script 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 script ( `job.tx `

) for a serial run:

#PBS -N matlab_example #PBS -l walltime=00:10:00 #PBS -l nodes=1:ppn=12 #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 fileIn order to run

`hello.m`

via the batch system, submit the `job.txt`

file with the following command:
qsub job.txtThis will run

`hello.m`

via the batch system, and all output from the running of the script will be saved in the `output.txt`

file.#### Toolboxes

To view a complete list of the currently INSTALLED toolboxes, in the MATLAB command line type the command `ver`

. OSC's current licenses support the following toolboxes (please contact oschelp@osc.edu for license-specific questions):

```
Bioinformatics_Toolbox
Communication_Toolbox
Control_Toolbox
Curve_Fitting_Toolbox
Data_Acq_Toolbox
Fuzzy_Toolbox
Image_Toolbox
Instr_Control_Toolbox
Neural_Network_Toolbox
Optimization_Toolbox
Distrib_Computing_Toolbox
PDE_Toolbox
RF_Toolbox
Robust_Toolbox
Signal_Toolbox
Statistics_Toolbox
Symbolic_Toolbox
Identification_Toolbox
Wavelet_Toolbox
```

#### Parallel Processing in MATLAB

MATLAB supports both implicit multiprocessing (multithreading) and explicit multiprocessing across multiple nodes.

##### Multithreading

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.

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. An example is given below:

#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

##### Parallel computing across multiple nodes

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.

### Usage on Ruby

#### Set-up on Ruby

`module load matlab`

. For a list of all available MATLAB versions and the format expected on Ruby, type: `module spider matlab`

. To select a particular software version, use `module load matlab/version`

. For example, use `module load matlab/r2014b`

to load MATLAB version 2014b on Ruby. #### Running MATLAB

The following command will start an interactive, command line version of MATLAB on either cluster system:

matlab -nodisplayIf 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

`matlab`

. 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.

#### Batch Usage on Ruby

When you log into ruby.osc.edu you are actually logged into a Linux box referred to as the login node. To gain access to the multiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request multiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info.

##### Interactive Batch Session

For an interactive batch session using the command line version of MATLAB, one can run the following command:qsub -I -X -l nodes=1:ppn=20 -l walltime=00:20:00

which requests one whole node with 20 cores ( `-l nodes=1:ppn=20`

), for a walltime of 20 minutes ( `-l walltime=00:20:00`

). 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 X11 forwarding on the compute node, so you can use the MATLAB GUI if you choose.You may adjust the numbers per your need.

#### Toolboxes

To view a complete list of the currently INSTALLED toolboxes, in the MATLAB command line type the command `ver`

. OSC's current licenses support the following toolboxes (please contact oschelp@osc.edu for license-specific questions):

```
Bioinformatics_Toolbox
Communication_Toolbox
Control_Toolbox
Curve_Fitting_Toolbox
Data_Acq_Toolbox
Fuzzy_Toolbox
Image_Toolbox
Instr_Control_Toolbox
Neural_Network_Toolbox
Optimization_Toolbox
Distrib_Computing_Toolbox
PDE_Toolbox
RF_Toolbox
Robust_Toolbox
Signal_Toolbox
Statistics_Toolbox
Symbolic_Toolbox
Identification_Toolbox
Wavelet_Toolbox
```

#### Parallel Processing in MATLAB

MATLAB supports both implicit multiprocessing (multithreading) and explicit multiprocessing across multiple nodes.

##### Multithreading

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 Ruby, the system will run as many threads as there are cores on the nodes requested. For the normal nodes, this mean matlab will start 20 threads to run on the 20 cores of the node. This is due to the whole node scheduling policy of Ruby (see Batch Specifics).

Multithreading increases the speed of some linear algebra routines, but if you would like to disable multithreading you may include the option " `-singleCompThread`

" when running MATLAB. An example is given below:

#PBS -N disable_multithreading #PBS -l walltime=00:10:00 #PBS -l nodes=1:ppn=20 #PBS -j oe module load matlab matlab -singleCompThread -nodisplay -r hello # end of example file

##### Parallel computing across multiple nodes

Parallel computing across multiple nodes is only available on Oakley.

## Further Reading

Official PDF documentation can be obtained from the MathWorks website.