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

整出这个英文版的说明,是因为我发现很多英语用户也在为这个问题烦恼。中文用户请看中文版©

本文发表于水景一页。永久链接:<http://cnzhx.net/blog/associate-m-file-with-matlab-editor/>。转载请保留此信息及相应链接。

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

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

雁过留声,人过留名

您的电子邮箱地址不会被公开。 必填项已用 * 标注

特别提示:与当前文章主题无关的讨论相关但需要较多讨论求助信息请发布到水景一页讨论区的相应版块,谢谢您的理解与合作!请参考本站互助指南
您可以在评论中使用如下的 HTML 标记来辅助表达: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>