Matlab R2007a 中存在保存路径的 Bug,症状如下:
当你修改了(增加或删除)搜索路径,并 savepath 后。以后每次启动 MATLAB ,会在 Command Window 的第一行显示下面信息:
Warning: Duplicate directory name: C:/Documents and Settings/c_c/My Documents/MATLAB.
而我们 File --> Set Path,进入路径设置对话框,在“MATLAB search path:”栏里可以看到只有一个上面提示中的目录,而并没有重复的目录。但却每次都提示这个 Warning,至少这会让你感觉很不爽。
一、Bug出处
事实上,造成上面的原因并不是真的多了一个提示中的目录,而是我们修改路径后
保存设置时出了问题(命令savepath存在bug!),问题就出在这个savepath.m文件上。
我们在 Matlab 的官网上也可以看到这个 bug 信息,如下:
如上所述,这个bug 存在于 Matlab R2007a 上,到了版本 R2007b 已经得到解决。
二、解决办法
官网上同时也给出了问题的解决办法,如下:
Exit MATLAB.
- Download the attached savepath.m file to replace the existing savepath.m at
matlabroot/toolbox/matlab/general/savepath.m
where matlabroot is the directory in which MATLAB is installed, which you can determine by running the matlabroot function in MATLAB.
- Start MATLAB from the Windows desktop shortcut or from Windows Start > Programs.
- Run savepath in the Command Window.
The warning should no longer appear.
如上所述,按以下步骤可解决此 bug :
1)下载修正后的 savepath.m 文件 (点击此处下载savepath.m )
2)如果你正在运行 Matlab,退出 Matlab
3)假如你的 Matlab 安装在目录 D:/Program Files/MATLAB 下,则进入目录
D:/Program Files/MATLAB/R2007a/toolbox/matlab/general 找到并删除这里的 savepath.m 文件,
4)将(1)步中下载的 savepath.m 文件 拷到此目录。
5)启动 Matlab,在 Command Window 输入 savepath 命令即可解决此问题
6)再次重起 Matlab,那个讨厌的 Warning 即会消失。
OVER