MATLAB is an incredibly powerful programming platform for scientific computing and analysis. With the ability to manipulate matrices, plot functions and data, implement algorithms, and interface with code in C/C++, Java, Python and more – MATLAB provides a flexible environment for engineers, scientists, and analysts.
While MATLAB is proprietary software from Mathworks, a free trial license allows you to explore the capabilities on your own Linux machine. This comprehensive guide will walk through how to fully install MATLAB, leverage the free trial, and hit the ground running on Linux.
Prerequisites Before Installing MATLAB
Before jumping into the installation process, we need to ensure the Linux environment has the proper packages to support running MATLAB:
- gcc & g++ compilers
- X Window System
- Dotnet Framework 2.0+
- Minimum of 2 GB RAM (4 GB recommended)
Use your Linux package manager to install any missing dependencies. For example on Ubuntu:
sudo apt update sudo apt install build-essential libx11-dev libxt-dev libxext-dev
This installs the base development tools, X Window system libraries, and extensions needed.
Specifically the gcc and g++ compilers are needed to build MEX-files allowing you to call MATLAB functions from C/C++ code. The X11 packages provide graphical interface functionality.
We can validate these components are correctly installed by checking versions:
gcc --version g++ --version xwininfo -version
Output should show 9.x.x builds of gcc/g++ and an X Window System version supporting X11:
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 version number: 11.0
For the Dotnet framework, ensure .NET Core Runtime 2.0+ is installed per Mathwork‘s system requirements.
Now we can proceed with the MATLAB installation knowing the Linux environment is ready.
Linux Distribution Compatibility
Mathworks actively tests and supports recent MATLAB versions on the following Linux distributions:
- Red Hat Enterprise Linux 8.x, 9.x
- SUSE Linux Enterprise Server 15 SP1, SP2, SP3, SP4
- Ubuntu 18.04 LTS, 20.04 LTS, 22.04 LTS
- Other distributions supporting glibc 2.17+ may work but without official support
Older distributions eventually lose compatibility as they go end of life. The table below summarizes the Linux releases still supported by current MATLAB versions at the time of writing:
| R2022b | R2022a | R2021b | |
| Red Hat 8 | Yes | Yes | Yes |
| SUSE 15 SP2/SP3 | Yes | Yes | Yes |
| Ubuntu 18.04 LTS | Yes | Yes | Yes |
So focus on installing MATLAB only on supported, maintained Linux distributions with recent patch versions.
Downloading MATLAB for Linux
Head over to the MATLAB download page and select the Linux version you need for your distribution and architecture (most likely 64-bit .iso file).
You have the choice of logging in with a Mathworks account to access trial licenses, or using an Activation Key if you already purchased MATLAB. For this guide, we‘ll cover the free trial route.
Move the downloaded .iso file to a dedicated directory for MATLAB:
mkdir ~/matlab mv matlab_R2020b_glnxa64.iso ~/matlab/
Installing MATLAB on Linux Step-By-Step
With the file in place, we‘re ready to install. Open a terminal in the destination folder:
cd ~/matlab
Mount the .iso so that Linux can interact with the MATLAB install files:
sudo mount -o loop matlab_R2020b_glnxa64.iso /mnt
Run the install script with sudo privileges:
sudo /mnt/install
The MATLAB installation wizard will launch…

Walk through the prompts:
- Choose Create an account if setting up the trial
- Enter you information to create a Mathworks account
- Accept the license agreement
- Leave the default installation path as /usr/local/MATLAB
- Select which MATLAB components to include (defaults are good)
- Let the installation run – this may take a few minutes
The default installation location is /usr/local/MATLAB which will symlink executables into /usr/local/bin to be in the path.
You can customize to another location meeting these criteria:
- Location is writable by the installation user
- Location is shared across users that need access
- Location has 5-10GB+ free space for MATLAB
The directory structure will contain:
/usr/local/MATLAB |-- bin # executables |-- extern |-- help |-- javabuilder |-- licenses |-- toolbox |-- sys +-- versioninfo
Choose component products smartly based on your toolkit needs. For example Image Processing, Machine Learning, Signal Processing, Optimization toolboxes etc. These can be expensive à la carte, so the trial is helpful for evaluating capabilities.
Overall expect 500MB+ to install with full documentation. Specific headless MATLAB Runtime deployments can be smaller.
Running MATLAB on Linux
When finished, the setup will provide a link to activate MATLAB Online to associate your new license.
You can then launch MATLAB directly from the command line now:
matlab
The familiar MATLAB interface will load on Linux!

Feel free to test out functionality, leverage documentation and examples, and ensure everything meets your needs.
The free trial gives you 30 days to take advantage. Just be sure to properly uninstall once done.
Developing with the MATLAB API
Beyond the interactive environment, developers can call MATLAB functions from external applications using the MATLAB API:
#include "matlabapi.h"int main() {
MATFile pmat; mxArray pa, *pm;
if (!(pmat = matOpen("func.m","r"))) return(1);
pa = matGetVariable(pmat, "a");
pm = engEvalString(ep,"func(a)");
matClose(pmat);
return;
}
This loads data from a .MAT file, executes a MATLAB function, and returns the variable.
For dynamically typed languages like Python, MATLAB provides pymatbridge to invoke runtime calls.
So you can directly leverage MATLAB‘s computational capabilities in an integrated development environment.
Compiling MEX Code
To tightly couple performance-critical code, MATLAB MEX files allow calling functions written in C/C++.
After gcc/g++ is installed, you can compile code right within MATLAB:
mex hello.c
Which will produce hello.mex* allowing:.
a = hello(123);
To control the compiler,optimization etc. we pass directives like:
mex -v COPTIMFLAGS=‘-O3 -fPIC‘ hello.c
Consult the Calling MEX guide for more details.
Proper use of MEX code can greatly improve performance in areas like machine learning and signal processing.
Alternative Open-Source Platforms
While MATLAB excels in analytical prototyping, having full source code access can be advantageous.
Free open-source alternatives like GNU Octave provide similar numeric computing with MATLAB compatibility:
| MATLAB | GNU Octave | |
|---|---|---|
| Core Language | MATLAB | Mostly compatible |
| Toolboxes | Extensive | Limited packages |
| GUI | Full IDE | Basic terminal |
| License | Commercial | GNU GPL |
So while Octave lacks the polished UI and breadth of toolboxes, you can freely inspect, modify, and extend the capabilities.
For developers needing source access, building upon Octave may suit. It uses the same data structures as MATLAB allowing some code reuse.
Uninstalling MATLAB on Linux
To fully uninstall:
sudo /usr/local/MATLAB/uninstall
Follow the prompts to remove all MATLAB files and folders from the system.
You can also delete the ~/matlab directory you created manually after.
Conclusion
Getting MATLAB running on the Linux operating system opens up a best-in-class tool for numerical computing. The free trial license gives you a month to evaluate the capabilities.
Hopefully this comprehensive guide provided a straight-forward process to download, install, activate, and launch MATLAB on a supported Linux distribution – as well as properly remove it after testing.
The investment to purchase a license will be well worth it for engineers, scientists, and developers needing a feature-packed programming environment integrating robust C/C++ code for performance. Additional platforms like Octave offer open-source alternatives balancing capabilities with source access.


