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

9 次查看(过去 30 天)
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.

回答(1 个)

Malay Agarwal
Malay Agarwal 2024-3-26
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!

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by