If you have a new instance of matlab opening each time you open a new file you can check these page for a lot of differente ways of fixing it.
On the official site:
- “Why is a new instance of MATLAB opened when I double-click on a MATLAB file in Windows Explorer even if I have one instance of MATLAB already open on my Windows 7 machine?”
http://www.mathworks.com/matlabcentral/answers/93468
On the forum:
- “associating .m files with matlab”
https://groups.google.com/forum/#!topic/comp.soft-sys.matlab/2-tMhgDKLvI
I have an old matlab installation and then I install the new one. After I de-install the old one, the problem arise.
For me worked this suggestion:
“Mohamed Talaat Harb” wrote in message
> The steps you did was right…the only thing missing that before opening Matlab and doing this steps you had to run it as administrator…(Right Click the Matlab shortcut and choose run as administrator)…
> Then in the command line you can write what ever you like without “Matlab can’t…” message
> cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.m’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
It worked for me.
You have to manually run Matlab as administrator (also if you already are). Then run the code above, restart matlab and it works !
I also run the same code with .mat and .fig extension.
So my code was:
cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.m’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.mat’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.fig’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
Before find this fix i tried to delete the extension, from explorer, manually from regedit, change the pathdef.m pernissions, but nothing worked utill the above solution. Enjoy.
UPDATE – March 2015
I was trying to do the same with Matlab 2014b 32bit and it failed, since now the “fileassoc” function is considered private. To fix it copy the file “fileassoc.m” from
“MATLAB 2014a\mcr\toolbox\matlab\winfun\private”
in a new folder in
“MATLAB 2014a/toolbox/matlab/winfun public”
and run (sometimes you have to replace the quotes since they could be replaced with non standard ones while publishing in wordpress):
fileassoc(‘add’, {‘.m’,’.mat’,’.mdl’,’.fig’,’.p’,’.mlprj’,’.mexw32′})
fileassoc(‘delete’, {‘.m’,’.mat’,’.mdl’,’.fig’,’.p’,’.mlprj’,’.mexw32′})cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.m’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.mat’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
cwd=pwd; cd([matlabroot ‘\toolbox\matlab\winfun\private’]); fileassoc(‘add’,’.fig’) ;cd(cwd); disp(‘Changed Windows file association. M-files are now associated with MATLAB.’);
I’ve also added write permission to the pathdef.m file, but I am not sure it was needed
(http://www.mathworks.com/matlabcentral/answers/93468-why-is-a-new-instance-of-matlab-opened-when-i-double-click-on-a-matlab-file-in-windows-explorer-even)
Enjoy