How to run one instance of matlab in linux when opening a .m file

6 views (last 30 days)
I am running matlab from linux POP OS. I have managed to write a .desktop file in my user applications folder to open MATLAB when I double click on a *.m file ; however, my new problem is that every matlab file i click on creates yet a new instance of MATLAB. I want MATLAB to beahve like in the windows environment where I can double click and open a few file in the same instance of matlab as a new page in the editor.
[Desktop Entry]
Type=Application
Name=MATLAB 2024a
Icon=/usr/share/icons/matlab_icon.png
Exec=/usr/local/MATLAB/R2024a/bin/matlab "open %f"
Categories=Development
Terminal=false
~
Thanks for any help.

Answers (1)

Malay Agarwal
Malay Agarwal on 26 Mar 2024
Hi Cyrus,
I understand that you want to associate MATLAB files in Linux so that they launch in the same MATLAB instance when double-clicked.
I tried the MATLAB CLI on different platforms (Windows, Linux and Mac) and in all cases, it launches a new instance of MATLAB. This suggests that a “.desktop” file where the “Exec” directive is a call to the MATLAB CLI cannot be used to get the desired behaviour since it will always launch a new MATLAB instance.
This also suggests that the behaviour as observed in Windows and Mac is part of MATLAB’s source code and the functionality has not been implemented for Linux. This is also confirmed by the following answer by MathWorks staff: https://www.mathworks.com/matlabcentral/answers/502862-how-to-open-multiple-matlab-files-in-one-instance-of-the-matlab-by-double-clicking-in-ubuntu.
Hope this helps!

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!