New to Linux and the open source world? We have compiled a huge list of resources to help you go through Linux and its distributions. Visit the full Linux guide page right now.
Matlab is one of the most famous and successful software projects ever. It’s the industry’s leading computing environment for all types of analytical/mathematical engineering works you may think of. It’s a fully functional programming language as well. I tend to think about it just like one of my professors told me many years ago: “What can you do in Matlab? You can do everything in Matlab”.
Many people are still under the illusion that Matlab does not work on Linux, and that it currently only works on Windows. This belief is false, and Linux has been officially supported by Matlab for many years now.
This tutorial will guide you through a full installation process to show you how to install Matlab on Linux.
Install Matlab on Linux
Of course, you know that Matlab is a proprietary software, so you’ll need to have a license in order to use it.
If you are a student, then you should check your university website for information related to where to obtain the software keys needed by the university students for Matlab. You may try to contact the information technology/help desk office in your university if you didn’t know where to search.
Otherwise, you’ll need to buy an individual license in order to use Matlab. You can do that from Matlab’s official website.
Download & Installation
Once you are ready, head to Matlab’s website and click on the download button. You’ll be required to sign in into your MathWorks account which contains the license key. Once you login, you’ll be able to download Matlab according to your operating system, click on the Linux download option:
After the file is downloaded, extract the file and the result should be a folder like matlab_R2019a_glnxa64, now open the terminal and run:
Just check that ~/Downloads/matlab_R2019a_glnxa64/ is the path of the extracted folder.
Now, the Matlab’s installer will start:
If you do have a MathWorks account – as you should – then simply click next and continue, but if you have the license key in a file given to you by someone in your work/study department, then you have to select the second option.
Then you’ll have to accept the license agreement:
Then you’ll have to sign in into your MathWorks account, simply write your username and password:
From here, you’ll be able to see the license that belongs to your account, select it and continue:
Here you can choose the default installation location of Matlab. Normally, you don’t need to do any change in here, but if you want, you can choose any installation location you want on your disk:
Then you can select the Matlab components you want to install:
After you click next, you’ll be prompted into this window. The first option you see allows you to instantly run Matlab and its other scripts from the command line. In other words, it will allow you to write matlab in the command line, and then the program would start. This will save you time in writing the full absolute path each time you want to run Matlab or one of its components, so make sure to select it:
Finally, you’ll see the installation summary, after which the installation will start:
Now, you can run matlab from the command line using its installation location like this:
Setting Up a Launcher
We don’t want to always open the terminal and run the above command each time we want to open Matlab. Instead, we simply want to run Matlab using an icon in the applications menu. Sadly, Matlab doesn’t create one for us automatically after the installation – like it should have done – so we’ll need to create the launcher manually.
First, we’ll need to get a nice icon for Matlab. Simply download this icon file, save it and put it in /usr/share/pixmaps folder (You’ll need root permissions to access that folder).
Now, run the following command:
sudo nano /usr/share/applications/matlab.desktop
And then paste the below text inside:
[Desktop Entry] Version=1.0 Type=Application Name=Matlab Comment=Matlab is a very good software. Keywords=matlab Exec=/usr/local/MATLAB/R2019a/bin/matlab Icon=matlab Terminal=true Categories=Office; StartupNotify=true
Save the file and exit. (Using CTRL + X, then hit Y, then Enter). Now, in your applications menu, you should see the Matlab icon:
Which if you click, Matlab will start:
A Brief About GNU Octave
GNU Octave is a free and open source software which its development started back in 1992. It’s also another computing environment for mathematical/analytical works or similar engineering tasks. A lot of people tend to think about GNU Octave as a free alternative to Matlab.
While the scripts you write on Matlab should may generally work under GNU Octave, the latter does not officially state that one of its goal is to be fully compatible with Matlab. GNU Octave also has extended syntax, meaning that some scripts written under GNU Octave will never work under Matlab.
Additionally, a lot of use cases seem to demonstrate that GNU Octave isn’t really capable of running all Matlab scripts out-of-the-box; there are a lot of errors and modifications that you’ll have to do manually on your scripts so that they can run under GNU Octave. GNU Octave is good for running simple m-files of Matlab, but not for complex or large ones. It also doesn’t contain nor support Matlab addons or an alternative to them, which are critical in a lot of scenarios. Matlab is superior in a lot of ways.
All of those reasons prevent us from recommending GNU Octave as a full free replacement for Matlab. But if you are not tied by industry/work restrictions, and you have time to learn, then you can adapt to GNU Octave’s syntax and use it as your main environment. You’ll find it in your official distribution’s repositories.
So far we have seen how to install Matlab on Linux and how to make it easy to run it any time we want.
Like we said, if Matlab is a critical software for your work, then you don’t need to worry about using it on Linux. It’s fully working with no problems or issues, including all its other addons and components, just as if you are running it under Windows.
If you have any comment about our tutorial, or Matlab on Linux or GNU Octave, we would love to hear them!