MATLAB Answers

9

How do I make a desktop launcher for MATLAB in Linux?

Asked by Ian Jessen on 6 Jan 2011
Latest activity Edited by kevin
on 11 Oct 2018
I don’t want to have to open a terminal window every time I want to launch MATLAB on Linux. I tried to make a Gnome launcher, but it does not seem to work. The command I gave was:
/usr/local/bin/matlab &
I see the process running, but now windows appear. What am I doing wrong?

  1 Comment

Is there a reason why Mathworks doesn't supply such Launcher with the installer?

Sign in to comment.

10 Answers

Answer by John
on 11 Jan 2011
 Accepted Answer

To have MATLAB open up from a launcher, you need to add the –desktop flag to the command field. For example:
/usr/local/matlab/bin/matlab desktop
If that does not work, try changing the launcher type from "Application" to "Application in terminal". If there is a MATLAB startup error, it won’t be displayed unless MATLAB is started with terminal.

  2 Comments

Why don't you supply a Desktop Launcher for Ubuntu Based distributions? Something that at the end of the installation create an launcher on the menu like in Windows.

Sign in to comment.


Answer by KimHan
on 21 Nov 2016
Edited by KimHan
on 21 Nov 2016

In your terminal, type sudo apt-get install matlab-support, press enter, and follow the instructions. It works for Ubuntu 16.0 LTE

  1 Comment

I have Ubuntu 16.04LTS and executed 'sudo apt-get install matlab-support' and it didn't work. No Matlab icons.
BTW, I tried doing this through the App center first. It gave weird installation errors and didn't work. Then I tried following the instructions on https://help.ubuntu.com/community/MATLAB :
1. Get an icon:
2. Get the launcher file:
sudo wget 'https://help.ubuntu.com/community/MATLAB?action=AttachFile&do=get&target=matlab-r2012a.desktop' -O /usr/share/applications/matlab.desktop)
That didn't work either.
Any suggestions? Could it be that I didn't enable the "make symbolic links" button when I installed Matlab?

Sign in to comment.


Answer by Tucker McClure on 26 Sep 2017

I seemed to have to do the least to get this to work, so I thought I'd share. I'm on Ubuntu 16.04 and installed with the defaults. I created ~/.local/share/applications/matlab_r2015a.desktop with the following contents:
[Desktop Entry]
Version=1.0
Type=Application
Name=MATLAB R2015a
Icon=matlab
Path=/home/tucker/dev
Exec=/usr/local/MATLAB/R2015a/bin/glnxa64/MATLAB -desktop -prefersoftwareopengl
Terminal=false
I then made it executable:
chmod +x matlab_r2015a.desktop
I then navigated to ~/.local/share/applications/ with the file browser (you may need to click View > Show Hidden Files to see .local) and dragged the matlab_r2015a.desktop file to the launcher bar. It showed up, I clicked on it, and it opened MATLAB.

  1 Comment

Yes, this worked for me on 2018a. Should be the right answer. Remember to change the path to your own home directory (or any directory that exists) or it will fail to launch.

Sign in to comment.


Answer by Eric
on 25 Jun 2015

If you're using Ubuntu, see this page: https://help.ubuntu.com/community/MATLAB

  0 Comments

Sign in to comment.


Answer by Julian Zimmer on 4 Nov 2016
Edited by Julian Zimmer on 4 Nov 2016

The following trick worked for me:
Suppose <install>/MATLAB is the folder where you installed MATLAB and you are using zsh as your preferred shell:
1. download the MATLAB logo from Wikipedia and save it as <install>/MATLAB/logo.png
2. go to ~/bin and create the following shell script and call it matlab:
#!/usr/bin/zsh
<install>/MATLAB/bin/matlab -desktop &
3. make matlab shell script executable
chmod +x matlab
4. in /usr/local/applications, create matlab.desktop (you have to be root). If there are other people using the same system use the personal applications folder of your respective distribution
#!/usr/bin/zsh
[Desktop Entry]
Name=MATLAB
Exec= /home/<yourUsername>/bin/matlab
Icon=<install>/MATLAB/logo.png
Terminal=false
Type=Application
Categories=Development;Math;Science;Education;
This will add MATLAB to your Menu and Application Starter.
5. Copy the file matlab.desktop file to your Desktop folder

  1 Comment

a rather complicated solution to do something so simple!! Its no wonder Linux is not catching on :(

Sign in to comment.


Answer by Martin
on 22 Nov 2012

I am trying to do the same, basically going in to the terminal each time is very inconvenient. Is there a way I can make a button to click rather than terminal?

  1 Comment

got this sorted now. thanks

Sign in to comment.


Answer by Taran Sachdeva on 16 Mar 2017

The problem is actually with creating an icon in Ubuntu itself more than anything else. Solution from Julian is very close to the working icon solution however, the number of steps for the icon can be further reduced to only two steps (at least in Ubuntu 16.04.2).
1. Install gksudo: The reason you want to install this is because you will be turning off the terminal when you create the icon. This is a small graphical interface with a forced sudo backend (more on that later)
sudo apt-get install gksudo
2. create icon: open terminal and enter the following command
sudo gedit ~/.local/share/applications/matlab.desktop
a blank text editor will open up. In that editor paste the following set and save
[Desktop Entry]
Name=MATLAB
Type=Application
Exec=gksudo -S "<matlab location>/matlab -desktop"
Terminal=false
Icon=<icon location>
Comment=MATLAB
Categories=Development;IDE;
if you search for "MATLAB" now you will see an icon that can be dragged and dropped to the launcher (Ubuntu's equivilant for windows taskbar) or desktop.
the "<matlab location>" is a placeholder for where your matlab installation is stored. By default, it should be store in the /usr/local/MATLAB/.....
the "<icon location>" is a placeholder for where the matlab icon should be stored. It can be a .png,.ico or .xmp .
Comments on what is going on in the background:
1. The gksudo is running the sudo as its backend (https://linux.die.net/man/1/gksudo), if your linux box has a password, it will ask you for it when you click the icon you have created using the above instruction. Since we turned the terminal off (line 5) there will be no way for you to enter this password and matlab will keep crashing. gksudo provides a GUI interface that will allow the user to input his/her password.
2. matlab -desktop, forces matlab to run in desktop mode with the full matlab shell

  1 Comment

hi,
what is the file that we need to open in "usr/local/MATLAB/..." there are many files there and I don't know which to select

Sign in to comment.


Answer by Thaddeus Song En Low on 6 Dec 2017

A little bit late to the train, but an alternative that one can use, not only for matlab but for other scripts also, for those in Ubuntu.
1) Install "alacarte"
sudo apt-get install alacarte
2) Run alacarte and select "new item". Provide the command (ie. the matlab script) and name. You can also provide a logo by clicking on an image file. If you don't have a logo, just download one off the web.
You can now launch matlab without a terminal.

  2 Comments

Thank you very much, I tried but I get an error message during the installation:
E: invalid operation alacarte
I managed to install it and it does launch but it crashes immediately.

Sign in to comment.


Answer by Mark
on 13 Apr 2018

For Fedora, I made some packages packages:
https://copr.fedorainfracloud.org/coprs/hmaarrfk/useful_launchers/
You may also want to edit the file `/usr/local/MATLAB/R20XXX/resources/MATLAB/en/branding.xml`, the keys with IDE_TITLE so that it matches up with the icon correctly. I mostly didn't want to create many different packages everytime matlab changes their Title.
Result:

  0 Comments

Sign in to comment.


Answer by kinblu
on 22 Jun 2018
Edited by kinblu
on 22 Jun 2018

After launching it from the terminal, I clicked on its icon in the Launcher and then selected "Add to Dash". Voila! (on Ubuntu 16.04 LTS)

  0 Comments

Sign in to comment.