How to open multiple matlab files in one instance of the matlab by double clicking in Ubuntu

12 views (last 30 days)
I want to be able to open matlab files in Ubuntu simply by doubly clicking on them (same like it is working on MacOs or Windows).
To do that I've added matlab to the list of applications and associated it to the *.m and *.fig files in my file manager. So now I can open *.fig and *.m files by double-clicking on them. The problem is that every new file is starting new instance of matlab instead of opening it in the already launched one.
Is it possible to fix it?
the matlab.desktop file that I'm using is:
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=matlab -desktop -r "open %f"
Name=MATLAB
Icon=/usr/share/icons/hicolor/48x48/apps/matlab.png
Categories=Development;Math;Science
Comment=Scientific computing environment
StartupNotify=true
StartupWMClass=com-mathworks-util-PostVMInit
matlab version is R2019a
Ubuntu version is 18.04.3

Answers (2)

Sai Sri Pathuri
Sai Sri Pathuri on 3 Mar 2020
Unfortunately, this is expected behavior on Linux. Only Windows and Mac have special implementations of double-click behavior. The desired double-click behavior is unavailable on Linux.
These are some alternatives you can try instead:
1. Dragging the .m file onto the MATLAB Command Window which caused MATLAB to run the file
2. By dragging it on top of the Editor window (if it was already visible) which caused MATLAB to edit the .m file

David Capan
David Capan on 10 Sep 2022
Exec=matlab -desktop -r "open %F"
This should work.
%f for one file, %F for multiple files.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!