How to open mat file into runing matlab.exe without opening a new one?

7 views (last 30 days)
Hello ,
I have a m-file. Whenever i click on it matlab opens, which is fine.
The problem is, if I have matlab open already it open another one.
I just want to open m-file in the existing matlab (if matlab.exe is already running) not sure how to fix this?

Accepted Answer

Abhishek Pandey
Abhishek Pandey on 17 Jul 2015
Hi Hesham,
In order to open a MAT-file using an existing session of MATLAB, follow the steps below:
If you’re running Windows XP or Vista, the following commands in MATLAB will reconfigure the associations of MATLAB-file for Windows for versions R2013a or earlier:
cd([matlabroot '\toolbox\matlab\winfun\private']);
fileassoc('add', {'.m','.mat','.mdl','.slx','.fig','.p','.mlprj'})
For versions R2013b or later, the path to fileassoc is instead:
cd([matlabroot '\mcr\toolbox\matlab\winfun\private']);
Note that, MATLAB must run with administrator privileges in order to perform the registry changes. So you will need to start MATLAB as Administrator, run the code above, and then quit MATLAB. Then try to open a MATLAB file via Windows explorer once to verify that MATLAB starts and then try to open another MATLAB file and verify that a second instance of MATLAB does not get started.
If this does not work, then check to make sure that you are not always running MATLAB with administrator privileges enabled. If so, then Windows itself (with User Account Control - UAC) is the actual cause of the problem. Windows (with UAC) will not allow the explorer to send DDE (Dynamic Data Exchange) messages to a process running with administrator privileges enabled.
If you’re running Windows 7 or later, follow the instructions in this doc .
I hope this helps!
- Abhishek

More Answers (0)

Categories

Find more on Startup and Shutdown 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!