MATLAB
This page summarises how MATLAB is provided for OxCIN users, how to select a version on shared Linux systems, and when to use compiled MATLAB for queue-based work.
Running MATLAB on shared systems
MATLAB is centrally installed on OxCIN Linux desktops. On systems that use Environment Modules, load the version you want before starting MATLAB.
To see which versions are available:
Typical output includes entries such as:
To load a specific version and start MATLAB:
If you just want the default or latest configured module:
Interactive use
For interactive work, use either:
- an OOD desktop session
- an OOD MATLAB session, where you choose the MATLAB version when creating the session
These are the recommended options when you need access to central datasets or a graphical MATLAB session on shared infrastructure.
Switching and checking versions
To switch from one MATLAB version to another in the same shell session:
To check what is currently loaded:
To remove MATLAB from the current shell environment:
Thread usage on shared systems
MATLAB will often try to use all CPUs visible to it. That may be reasonable on a personal machine, but on shared systems or scheduled resources it can lead to poorer performance or unfair resource use.
When using SLURM-managed resources, request the threads you need and make sure your MATLAB workload is configured sensibly for that allocation. In practice, limiting MATLAB to the number of threads you actually requested can improve performance and reduce contention.
Licensing
MATLAB is available to University members under the University agreement. In practice, there are three common cases:
- OOD cluster systems use centrally managed licensing and centrally maintained installations.
- Personally owned or operated computers should normally use individual MathWorks licensing made available through the University.
- Devices that need MATLAB without internet access, or that support critical offline operation, may require a standalone licence.
If you run into licensing or access issues on centrally managed systems, contact computing-help@oxcin.ox.ac.uk.
For the full licensing and toolbox position, refer to the University MATLAB guidance linked from the OxCIN source page.
Compiling MATLAB for queue-based workloads
For non-interactive work submitted to queues, compiled MATLAB is preferred where possible.
Compiling MATLAB code can help when:
- you want to run many jobs without depending on interactive MATLAB licensing
- you need to distribute code to users who do not have MATLAB installed
- you want a more repeatable deployment process for cluster jobs
Be aware that compiled MATLAB binaries are platform-specific. For example, code compiled on macOS will not run on the Linux cluster.
Using deploytool
MATLAB includes deploytool to help build standalone applications.
Start it from within MATLAB:
The general workflow is:
- Create a new project.
- Choose Standalone Application.
- Add your main
.mfile. - Add helper files or resources that are not automatically discovered.
- Build the package.
If your code calls functions indirectly using eval, add those files explicitly because the compiler may not find them automatically.
Running compiled programs
Compiled applications usually include a wrapper script such as run_my_function.sh. That script sets up the MATLAB Compiler Runtime (MCR) environment and then launches the binary.
Example:
cd my_function/distrib
./run_my_function.sh /opt/fmrib/MATLAB/MATLAB_Compiler_Runtime/v717 arg1 arg2
The MCR version must match the MATLAB version used to compile the program.
Makefile-based builds
If you want a repeatable command-line build process, you can compile with mcc from a Makefile-based workflow instead of using the GUI tooling. This is useful for scripted builds and reproducible packaging.
Build the compiled version with:
MATLAB Compiler Runtime
Compiled MATLAB programs require the MATLAB Compiler Runtime (MCR). Shared systems provide MCR versions through Environment Modules.
To list what is available:
To identify which runtime version a compiled application needs, use the MATLAB command:
Common gotchas when compiling
- Command-line arguments arrive as text, so compiled applications may need to convert numeric inputs explicitly.
- Functions called via
evalare not reliably discovered by the compiler unless you add them yourself. - The MATLAB path is effectively baked into the compiled application, so external code should be included deliberately rather than assumed to exist at runtime.
For example, deployed code may need explicit argument conversion: