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

1,176 ビュー (過去 30 日間)
Ian Jessen
Ian Jessen 2011 年 1 月 6 日
コメント済み: Dhananjay Rana 2024 年 3 月 25 日 20:18
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?
  5 件のコメント
Tim Darrah
Tim Darrah 2020 年 5 月 12 日
Couldn't have been said better...
Calin Bira
Calin Bira 2022 年 3 月 2 日
try to run as such: /usr/local/bin/matlab -desktop

サインインしてコメントする。

採用された回答

John
John 2011 年 1 月 11 日
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.
  10 件のコメント
Randall Pittman
Randall Pittman 2021 年 3 月 12 日
@Christopher Wong It is, but it's just hard to find.
See
under "Input Arguments"
Dhananjay Rana
Dhananjay Rana 2024 年 3 月 25 日 20:18
thanks a ton! it really helped me a lot!

サインインしてコメントする。

その他の回答 (15 件)

KimHan
KimHan 2016 年 11 月 21 日
編集済み: KimHan 2016 年 11 月 21 日
In your terminal, type sudo apt-get install matlab-support, press enter, and follow the instructions. It works for Ubuntu 16.0 LTE
  33 件のコメント
Tiago
Tiago 2023 年 10 月 30 日
It works in Ubuntu 22.04 with Matlab R2023b too.
Zhu
Zhu 2023 年 12 月 18 日
Works well on Ubuntu 20.04 with Matlba R2023b.
But how do yall configure the Gcc in the instructions?

サインインしてコメントする。


Tucker McClure
Tucker McClure 2017 年 9 月 26 日
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.
  7 件のコメント
Cesar Julian Cerpa Diaz
Cesar Julian Cerpa Diaz 2020 年 9 月 8 日
i used this way to fix my icon desktop on manajaro and that's it. thanks
Isidro Losada López
Isidro Losada López 2020 年 11 月 11 日
In my case, I had problems with the graphics at some point. I found a solution somewhere (I really don't remember where, sorry) that not only solved my problem, but my graphics improved consederably. You just have to change a line in the matlab.desktop file:
Exec=env MESA_LOADER_DRIVER_OVERRIDE=i965 /usr/local/bin/matlab -desktop -prefersoftwareopengl
It worked for me in Ubuntu 18.04 LTS and now in Ubuntu 20.04 LTS!

サインインしてコメントする。


Trevor Moon
Trevor Moon 2021 年 9 月 8 日
1. Create a linux .desktop file
touch ~/.local/share/applications/matlab.desktop
2. Add/copy relevant details for app launcher
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/path/to/matlab -desktop
Name=MATLAB RXXXXx
Icon=/path/to/icon
Comment=MATLAB
where /path/to/matlab is recommended to use usr/local/MATLAB/RXXXXx/bin/glnxa64/MATLAB and /path/to/icon is usr/local/MATLAB/RXXXXx/bin/glnxa64/cef_resources/matlab_icon.png
3. Make the file executable
chmod +x ~/.local/share/applications/matlab.desktop
4. Test the application launcher from the menu
From here, I had issues with the icons/descriptions to show. To fix this, I did
5. Move matlab.desktop to the shared applications folder
sudo mv ~/.local/share/applications/matlab.desktop /usr/share/applications
sudo is required since the root folder is protected
  1 件のコメント
Arslan Yahya
Arslan Yahya 2022 年 9 月 24 日
You can skip step 5., if you remember the '/' in the start of "/usr/local/MATLAB/RXXXXx/bin/glnxa64/cef_resources/matlab_icon.png"

サインインしてコメントする。


Eric
Eric 2015 年 6 月 25 日
If you're using Ubuntu, see this page: https://help.ubuntu.com/community/MATLAB

Julian Zimmer
Julian Zimmer 2016 年 11 月 4 日
編集済み: Julian Zimmer 2016 年 11 月 4 日
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 件のコメント
Steve Grobler
Steve Grobler 2017 年 2 月 11 日
a rather complicated solution to do something so simple!! Its no wonder Linux is not catching on :(

サインインしてコメントする。


Taran Sachdeva
Taran Sachdeva 2017 年 3 月 16 日
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
  2 件のコメント
gorilla3
gorilla3 2017 年 11 月 20 日
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
Mohsen Malayjerdi
Mohsen Malayjerdi 2019 年 11 月 16 日
Hi, you need to address like this:
usr/local/MATLAB/R2019b/bin/matlab
but you should consider your version. The run file is on the bin folder

サインインしてコメントする。


Thaddeus Song En Low
Thaddeus Song En Low 2017 年 12 月 6 日
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.
  3 件のコメント
gorilla3
gorilla3 2017 年 12 月 17 日
I managed to install it and it does launch but it crashes immediately.
Salma Omer
Salma Omer 2020 年 7 月 16 日
sorry, but how can I run alacarte??

サインインしてコメントする。


Rachel Allcock
Rachel Allcock 2019 年 6 月 28 日
編集済み: Rachel Allcock 2019 年 6 月 28 日
Fairly straightforward using Xubuntu 18.04 (XFCE) using the menu edit function with the command path:
/usr/local/MATLAB/R2019a/bin/matlab
but the key is to check the "Run in Terminal" box otherwise it won't start. You'll see the Terminal run in the background but it launches the full desktop.

Zoltán Gál
Zoltán Gál 2023 年 9 月 19 日
Update for 2023:
Matlab R2023b Linux installer still does not create a shortcut which is annoying. However, when making one manually, Mint 21 Cinnamon offers a MatLab icon among the default icons. So it took literally 20 seconds to solve this minor annoyance in life. Also, the Mint icon is stylized and I think it fits better than the default, so it's a win for me.

Martin
Martin 2012 年 11 月 22 日
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 件のコメント
Martin
Martin 2013 年 3 月 4 日
got this sorted now. thanks

サインインしてコメントする。


Mark
Mark 2018 年 4 月 13 日
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:

kinblu
kinblu 2018 年 6 月 22 日
編集済み: kinblu 2018 年 6 月 22 日
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)

Qianqian Fang
Qianqian Fang 2019 年 1 月 17 日
The launcher approach does not work properly after I upgraded Ubuntu from 14.04 to 16.04. Basically, all envrionment variables defined in my ~/.bashrc are not inheriented in the MATLAB environment, making it impossible to link to libraries in the non-standard locations, such as libcudart etc.
This did work well in Ubuntu 14.04. Is this a known problem?
thanks

Thomas Friedrich
Thomas Friedrich 2020 年 8 月 12 日
For those struggeling with the environment variables / library location setup: The solution I am using now, is to use a bash script instead of the classical launcher. In this bash script the environment variables can be set prior to actually running matlab. For CUDA-10.0 the following would work:
#!/bin/bash
export CUDA_PATH=/usr/local/cuda-10.0
export CUDA_HOME=$CUDA_PATH
export CUDA_BIN_PATH=$CUDA_PATH/bin
export CUDA_LIB_PATH=$CUDA_PATH/lib64
# set PATH so it includes users private bin directories
PATH=$HOME/bin:$HOME/.local/bin:$PATH
PATH=/usr/bin:$PATH
PATH=$MATLAB_DIR:$PATH
PATH=$MATLAB_BIN:$PATH
PATH=$CUDA_BIN_PATH:$PATH
export PATH
LD_LIBRARY_PATH=$CUDA_LIB_PATH:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
/usr/local/MATLAB/R2019b/bin/glnxa64/MATLAB -desktop
Saving that script as 'run19b' in some place the OS is looking for binaries, one can then create a launcher like that:
[Desktop Entry]
Type=Application
Name=MATLAB R2019b
Icon=/usr/local/MATLAB/R2019b/bin/glnxa64/cef_resources/matlab_icon.png
Path=/home/thomas
Exec=run19b
Terminal=false
Obviously this approach can be extended to whatever library one would want to add and I guess it'll work on most Linux distros. I tested it on Mint 19 (Ubuntu 18.04).

Hernan Mojica
Hernan Mojica 2021 年 10 月 7 日
編集済み: Hernan Mojica 2021 年 10 月 7 日
Once time you have Matlab installed, for Ubuntu 21.04 follow nexts steps :
  • Open a comand terminal.
  • Create a desktop shorcout :
nano ~/Desktop/Matlab
  • Copy-paste bellow lines:
[Desktop Entry]
Version=1.0
Type=Application
Name=MATLAB
Exec=/usr/local/MATLAB/R2021b/bin/./matlab
Icon=/usr/local/MATLAB/R2021b/resources/coreui/matlab/splash.png
Terminal=false
  • Go to the path /Desktop in the terminal and copy-paste the following:
chmod +x Matlab
  5 件のコメント
Piero Mana
Piero Mana 2022 年 8 月 18 日
This was essential, thank you!
VC
VC 2022 年 10 月 27 日
[Desktop Entry]
Type=Application
Terminal=false
MimeType=text/x-matlab
Exec=/usr/local/MATLAB/R20xyz/bin/matlab -desktop
Name=MATLAB
Icon=matlab
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
This works for me (Fedora 36). The one suggest by @Hernan Mojica leads to a crash post splash screen.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by