Associate m-file with MATLAB Editor

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

  1. Open the MATLAB program;
  2. 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!')
  3. Locate a .m file (M-file) in a folder in your computer;
  4. Right click this .m file, navigate to Open with, then Choose a default program(C);
  5. 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):

    Choose MATLAB Editor to open M-file

    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

  1. Open a folder, navigate to Tools and Folder Options in the menu bar;
  2. 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.
  3. If this doesn’t work, please continue reading the following section.

3. Notes

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.

MATLAB Editor preference



2 条关于 “Associate m-file with MATLAB Editor” 的评论

  1. Thanks a lot! I’ve been looking everywhere for this and your simple solution helped :)

谢谢您的理解 :-)