If you can’t open a M-file by double clicking on the file icon, you should read this. I’ve been trying so hard to find the way to re-associate M-file with MATLAB Editor, but not MATLAB it self. In this article, I’ll show how to re-associate M-file with MATLAB Editor in Windows XP and Windows 7.
When you loose the associating between M-file and MATLAB Editor, it’s easy to associate m-file to MATLAB in Windows. But if you do this, every time you double click a m-file will open a new MATLAB process. It’s a little annoying, right?
So this is the way to associate M-file to MATLAB Editor but not MATLAB itself.
1. in Windows 7
- Open the MATLAB program;
- Copy and paste the following commands group in MATLAB command line and hit enter to run it:
commandwindow; 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. Congratulations!')
- Locate a .m file (M-file) in a folder in your computer;
- Right click this .m file, navigate to Open with, then Choose a default program(C);
- A window like below would open now, click to choose MATLAB, then click OKto save the settiing (sorry for the confusing Chinese in the graph):
If you choose MATLAB Starter Application in the next, every time you double click a m-file will open a new MATLAB process.
This magic command group is mentioned here.
2. in Windows XP
- Open a folder, navigate to Tools and Folder Options in the menu bar;
- In the popup windows, click File Types, locate and choose the file type of M-file below the Registered File Types area, then click Restore below it.
- If this doesn’t work, please continue reading the following section.
If you had changed the Editor/Debugger Preferences in MATLAB Preferrences page ( at File – Preferences – Editor/debugger ), maybe you should change it back to make your new setting take effect.