28

I recently installed Matlab R2013a and it is working fine, however the only way I can start it is by running /usr/local/MATLAB/R2013a/bin/matlab in the terminal. If I type in matlab it says command not found, and I can't seem to get an icon in the side-bar launcher. How can I make it so I can run from the command matlab or from a launcher?

Edit: I have created a link so I can launch it by typing matlab in the terminal. I still can't get the unity icon launcher working though. I managed to create an icon via a matlab.desktop file in /usr/share/applications. When I click it, it launches Matlab, but after the initial loading screen Matlab shuts down instead of launching the application. It works through the terminal though. My matlab.desktop file is:

[Desktop Entry]
Type=Application
Name=Matlab
Comment=Matlab R2013a
Icon=/usr/share/icons/Matlab.png
Exec=/usr/local/MATLAB/R2013a/bin/matlab
Categories=Office
Terminal=false`
1
  • you sure the matlab.desktop file has executable permissions? If it does not, it won't launch. Oct 9, 2014 at 9:41

10 Answers 10

21

The lock to launcher is indeed not working for matlab. There is however a .desktop file that is part of the Matlab installation.

sudo ln /usr/share/app-install/desktop/matlab-support:matlab.desktop /usr/share/applications/matlab.desktop

You have to update a few things in this file (matlab.desktop):

[Desktop Entry]
X-AppInstall-Package=matlab-support
X-AppInstall-Popcon=3
X-AppInstall-Section=multiverse

Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop
Name=MATLAB
Icon=_usr_share_icons_hicolor_48x48_apps_matlab
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit

X-Ubuntu-Gettext-Domain=app-install-data

Give the icon an absolute file path by changing the icon path above to

Icon=/usr/share/app-install/icons/_usr_share_icons_hicolor_48x48_apps_matlab.png

And change:

Terminal=true

Now you should be able to lock the icon to the launcher as well as start matlab from there.

6
  • This is working.
    – eccstartup
    May 3, 2015 at 10:46
  • 7
    And Terminal=true is not required.
    – eccstartup
    May 3, 2015 at 10:46
  • This is a nice and complete answer +1. @Isaac Vandermeulen should consider accepting this.
    – NKN
    Feb 14, 2016 at 0:49
  • FYI: If you use the -desktop argument with the matlab command you don't need Terminal=true in the launcher file Mar 21, 2017 at 8:08
  • @TylerDurden. Thanks. That used to be necessary, so I'll keep it there as reference. Apr 12, 2017 at 15:06
12

To add an entry to the launcher and some other features, install the matlab-support package:

sudo apt-get install matlab-support

https://help.ubuntu.com/community/MATLAB

2
  • 1
    It works just fine! May 17, 2019 at 17:28
  • 3
    This should be accepted as best answer.
    – Danijel
    Apr 27, 2021 at 12:56
10

For me this works perfectly ...

Open a terminal and then

1.download your own icon-

sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png

2.give your access permission

sudo touch /usr/share/applications/matlab.desktop

3.edit your .desktop file

sudo gedit /usr/share/applications/matlab.desktop

4.and paste the following into the document.

#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Icon=/usr/share/icons/matlab.png
Name=MATLAB R2014a
Comment=Start MATLAB - The Language of Technical Computing
Exec=matlab -desktop
Categories=Development;

that's it..! Save, and you should have a new desktop shortcut in your launcher

6

In your matlab.desktop file, you need to specify that you want to execute in the desktop.

Your Exec= should look like this:

 Exec=/usr/local/MATLAB/R2013a/bin/matlab -desktop
4

For Ubuntu 16.04 and MATLAB R2016b

Find your preferable picture in .png format and rename it matlab.png.

  1. Execute:

    sudo cp matlab.png /usr/share/pixmaps/
    

    The above command copies your icon to the appropriate folder.

  2. Execute:

    sudo gedit /usr/local/share/applications/matlab.desktop
    

    Then copy the following lines on matlab.desktop:

    [Desktop Entry]
    X-AppInstall-Package=matlab-support
    X-AppInstall-Popcon=10
    X-AppInstall-Section=multiverse
    Version=1.0
    Type=Application
    Terminal=false
    Exec=/usr/local/MATLAB/R2016b/bin/matlab -desktop
    Name=MATLAB
    Icon=/usr/share/pixmaps/matlab.png
    Categories=Development;Math;Science
    Comment=Scientific computing environment
    StartupNotify=true
    StartupWMClass=com-mathworks-util-PostVMInit
    X-Ubuntu-Gettext-Domain=app-install-data
    
  3. Go on Dash and type matlab.

  4. Pick the icon from Dash and move in onto Launcher.

Τέλος! The end!

2

To my experience by far, the far simplest solution I have figured out yet is to simply install "matlab-support" through apt-get. It solves not only this issue but others as well. Just pop open a terminal and type

   sudo apt-get install matlab-support -y

It will ask for the location of Matlab. Mine is at /usr/local/MATLAB/R2017b.

1
  • works for me! Faster than making a .dekstop file
    – gannex
    Oct 30, 2023 at 3:54
0

Create a symbolic link in /usr/local/bin, i.e. as su

ln -s /usr/local/MATLAB/R2013a/bin/matlab /usr/local/bin/matlab

Once MATLAB is running, an icon should appear in the launcher toolbar. Right click it and lock it to the launcher.

1
  • 1
    That works so I can run it by typing matlab in the terminal. However, the lock to launcher is not working. Is there a way to make it show up when I search matlab in the unity launcher or so that I can have a desktop icon for it?
    – user232990
    Jan 8, 2014 at 3:52
0

Ubuntu 18.04 For me this works perfectly ...

Open a terminal and then

  1. Download your own icon:

    sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png
    
  2. Create .desktop file:

    sudo touch /usr/share/applications/matlab.desktop
    
  3. Edit your .desktop file

    sudo gedit /usr/share/applications/matlab.desktop
    
  4. Paste the following into the .desktop file:

    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Type=Application
    Icon=/usr/share/icons/matlab.png
    Name=MATLAB R2018a
    Comment=Start MATLAB - The Language of Technical Computing
    Exec=matlab -desktop
    Categories=Development;
    
0

Just create a file with notepad: matlab.desktop And copy the code below:

[Desktop Entry]
Version=1.0
Type=Application
Name=MATLAB
Exec=/home/**USER**/MATLAB/R2023b/bin/matlab -desktop
Icon=/home/**USER**/MATLAB/R2023b/resources/coreui/matlab/splash.png
Terminal=false

Then save the file in the folder: Desktop

-1

I had the same problem, and fund that much of the difficulty came from Matlab installing the .desktop file into ~/.local/share/applications/, rather than /usr/share/applications/. With that in mind, my solution:

  1. Ensure that you can launch matlab by typing matlab in terminal. If not, then you can install a sym link to do so, or replace my matlab commands below with the full path to the matlab executable.

  2. Download a matlab icon and save it to ~/.local/share/icons/matlab.png

  3. Create a new file: ~/.local/share/applications/matlab_version.desktop with the contents: [Desktop Entry]
    Encoding=UTF-8 Version=1.0 Type=Application Name=MATLAB Icon=matlab.png Exec=matlab -desktop StartupNotify=fals[ Terminal=false

  4. Check that the file you just created (matlab_version.desktop) has permissions set to be executable.

  5. Navigate to ~/.local/share/applications/ using nautilus file explorer, and then double click on matlab_version (it hides the file extension here)

  6. That should launch matlab. If it works, then right-click on the matlab icon in the unit launcher and then select 'lock to launcher'. If it doesn't work, then check that the file has execute permissions, and that your sym link is working.

You must log in to answer this question.