Matlab

MATLAB is a high-level technical computing language and interactive environment for algorithm development, data visualization, data analysis, and numeric computation. More information can be found at: http://www.mathworks.com/

Matlab on the HPCC

Interactive Matlab Sessions

  • Graphical on the FastX HPC3 Desktop:
qlogin -pe openmp 2
matlab -desktop
  • Textual:
qlogin -pe openmp 2
matlab -nodesktop

Submitting a Matlab Job

Create Matlab Commands File

Create a .m file with your commands, for example:

for i=1:1024
    A(i) = sin(i*2*pi/1024);
end

disp(A)

Create Matlab Job Script

Create a .sh file with at least the following contents:

#!/bin/bash

matlab -nodisplay -nodesktop -nosplash < your-commands-file-1.m

or if your Matlab command file calls functions in separate function files:

#!/bin/bash

matlab -nodisplay -nodesktop -nosplash < your-commands-file-1.m your-func-1.m your-func-2.m

Submit Matlab Job

More information: HPCC Job Management

Parallel Matlab on the HPCC

Remember HPCC Job Management with job limits for job queues.
  • Required to use parpool, run (on the command line, not in MATLAB): setup-parMatlab (this sets up your parallel environment in Matlab). You only need to do this one time. After that, all Matlab sessions will be ‘ready for parallel’.
  • To open a normal parallel matlab session, in your Matlab, use the myPoolStart() function:

Usage of myPoolStart.m Function

The myPoolStart() function is in the /usr/local/demo/Matlab/parallel folder on all HPC3 systems. You can use the other files in that directory to build your own job scripts.

With MPI (multi-server) Workers

Start a master (could be Matlab graphical or not):

qlogin -pe openmp 2 -l m_mem_free=2G

Start Matlab and run the function:

# if you need > 2G RAM / worker:
export MATLAB_WORKER_RAM=3G
matlab -nodisplay
> addpath /usr/local/demo/Matlab/parallel
> myPoolStart("Wharton_HPC3_Matlab_R2023a", 16)
... do your parallel work!
> poolobj = gcp('nocreate'); 
> delete(poolobj)

With SMP (local) Workers

If you only need 8 or less workers (would be running on 4 cores, max), you should instead use the function like:

qlogin -pe openmp 4 -l m_mem_free=3G
matlab -nodisplay
> addpath /usr/local/demo/Matlab/parallel
> myPoolStart("Processes", 8)
... do your work!
> poolobj = gcp('nocreate');
> delete(poolobj)

“Processes” starts a lot faster.

That function can be used in a job script as well.

Matlab on my Laptop and Desktop

Wharton Site License!

Wharton pays for a Matlab site license for all Faculty, Staff, and Students. It expires annually on September 1st, and includes Base Matlab, and the following toolboxes:

Site Licensed Toolboxes

  • Simulink
  • Bioinformatics Toolbox
  • Communications System Toolbox
  • Computer Vision System Toolbox
  • Control System Toolbox
  • Curve Fitting Toolbox
  • DSP System Toolbox
  • Data Acquisition Toolbox
  • Database Toolbox
  • Datafeed Toolbox
  • Econometrics Toolbox
  • Financial Instruments Toolbox
  • Financial Toolbox
  • Fixed-Point Designer
  • Fuzzy Logic Toolbox
  • Global Optimization Toolbox
  • Image Acquisition Toolbox
  • Image Processing Toolbox
  • Instrument Control Toolbox
  • MATLAB Builder EX
  • MATLAB Builder JA
  • MATLAB Builder NE
  • MATLAB Coder
  • MATLAB Compiler
  • MATLAB Report Generator
  • Mapping Toolbox
  • Model Predictive Control Toolbox
  • Neural Network Toolbox
  • Optimization Toolbox
  • Parallel Computing Toolbox
  • Partial Differential Equation Toolbox
  • Robust Control Toolbox
  • Signal Processing Toolbox
  • SimBiology
  • SimMechanics
  • Simscape
  • Simulink 3D Animation
  • Simulink Coder
  • Simulink Control Design
  • Simulink Design Optimization
  • Spreadsheet Link EX
  • Stateflow
  • Statistics Toolbox
  • Symbolic Math Toolbox
  • System Identification Toolbox
  • Trading Toolbox
  • Vehicle Network Toolbox
  • Wavelet Toolbox
  • xPC Target

Wharton faculty, staff, and PhDs with Wharton-owned computers

Please contact your Academic Distributed Representative for further assistance.

Wharton students with personally-owned computers

Wharton now licenses Matlab and a host of awesome Matlab toolboxes for all students.

  • Follow the directions HERE