MATLAB 2013b .m 文件关联

使用绿色版的MATLAB无法自动关联.m文件,在网上查到的解决办法是,在MATLAB里运行如下命令:

cwd=pwd;
cd([matlabroot '\toolbox\matlab\winfun\private']);
fileassoc('add',{'.m','.mat','.fig','.p','.mdl',['.' mexext]});
cd(cwd);
disp('Changed Windows file associations. FIG, M, MAT, MDL, MEX, and P files are now associated with MATLAB.');

 

但运行时却提示:Undefined function 'fileassoc' for input arguments of type 'cell'.

原来MATLAB 2013中修改了fileassoc.m文件的路径,新的路径为:[matlabroot '\mcr\toolbox\matlab\winfun\private'],因此执行如下命令便可解决问题:

cwd=pwd;
cd([matlabroot '\mcr\toolbox\matlab\winfun\private']);
fileassoc('add',{'.m','.mat','.fig','.p','.mdl',['.' mexext]});
cd(cwd);
disp('Changed Windows file associations. FIG, M, MAT, MDL, MEX, and P files are now associated with MATLAB.');

执行完毕后,找到想要打开的.m文件,右键->打开方式->选择默认程序,选中MATLAB (R2013b),并勾选“始终使用选择的程序打开这种文件”,确定即可。以后双击.m文件会默认使用MATLAB Editor打开。

posted @ 2015-07-24 10:51  俞夕  阅读(1992)  评论(0编辑  收藏  举报