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.

Steps to Install Matlab on Linux

Prerequisites

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

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

install matlab on linux 5

  1. 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:
sudo ~/Downloads/matlab_R2019a_glnxa64/install

Just check that ~/Downloads/matlab_R2019a_glnxa64/ is the path of the extracted folder.

  1. Now, the Matlab’s installer will start:

install matlab on linux 7

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.

  1. Then you’ll have to accept the license agreement:

install matlab on linux 9

  1. Then you’ll have to sign in into your MathWorks account, simply write your username and password:

install matlab on linux 11

  1. From here, you’ll be able to see the license that belongs to your account, select it and continue:

install matlab on linux 13

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

install matlab on linux 15

  1. Then you can select the Matlab components you want to install:

install matlab on linux 17

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

install matlab on linux 19

  1. Finally, you’ll see the installation summary, after which the installation will start:

install matlab on linux 21

  1. Now, you can run matlab from the command line using its installation location like this:
/usr/local/MATLAB/R2019a/bin/matlab

Setting Up a Matlab Launcher on Linux

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.

  1. 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
  1. 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
  1. Save the file and exit. (Using CTRL + X, then hit Y, then Enter). Now, in your applications menu, you should see the Matlab icon:

install matlab on linux 23

Which if you click, Matlab will start:

install matlab on linux 25

That’s it!

GNU Octave: Open Source Matlab Alternative

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.

Conclusion

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!

Subscribe
Notify of
guest

3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Newsletter

Enter your email address to subscribe to our newsletter. We only send you an email when we have a couple of new posts or some important updates to share.

Recent Comments

Open Source Directory

Join the Force!

For the price of one cup of coffee per month:

  • Support the FOSS Post to produce more content.
  • Get a special account on our website.
  • Remove all the ads you are seeing (including this one!).
  • Get an OPML file containing +70 RSS feeds for various FOSS-related websites and blogs, so that you can import it into your favorite RSS reader and stay updated about the FOSS world!