当我输入时
在ShowEmptyFile中,看起来像是空文件
也许我的edit.m文件有问题?还是某个设置导致新的具有代码的edit.m文件抛出错误?有什么想法吗?
edit somenewfile.m
在我的 Matlab R2010a 命令窗口中,它给出了这个错误
??? Error using ==> edit at 57
Neither 'somenewfile' nor 'somenewfile.m' could be found.
在我工作的另一台安装了R2012a版本的电脑上,这个命令可以正常运行并创建一个新文件。但是在2010版本中有什么不同吗?
我尝试修改edit.m文件,但担心会弄乱它。下面是出错的部分:
try
if (nargin == 0)
openEditor;
else
for i = 1:nargin
argName = translateUserHomeDirectory(strtrim(varargin{i}));
if isempty(argName)
openEditor;
else
checkEndsWithBadExtension(argName);
if ~openInPrivateOfCallingFile(argName)
if ~openOperator(argName)
if ~openWithFileSystem(argName, ~isSimpleFile(argName))
if ~openPath(argName)
showEmptyFile(argName);
end
end
end
end
end
end
end
catch exception
throw(exception); % throw so that we don't display stack trace
end
在ShowEmptyFile中,看起来像是空文件
%--------------------------------------------------------------------------
% Helper function that displays an empty file -- taken from the previous edit.m
% Now passes error message to main function for display through error.
function showEmptyFile(file)
errMessage = '';
errID = '';
% If nothing is found in the MATLAB workspace or directories,
% open a blank buffer only if:
% 1) the given file is a simple filename (contains no qualifying
% directories, i.e. foo.m)
% OR
% 2) the given file's directory portion exists (note that to get into
% this method it is implied that the file portion does not exist)
% (i.e. myDir/foo.m, where myDir exists and foo.m does not).
[path fileNameWithoutExtension extension] = fileparts(file);
if isSimpleFile(file) || (exist(path, 'dir') == 7)
% build the file name with extension.
if isempty(extension)
extension = '.m';
end
fileName = [fileNameWithoutExtension extension];
% make sure the given file name is valid.
checkValidName(fileName);
% if the path is empty then use the current working directory.
% else use the fully resolved version of the given path.
if (strcmp(path, ''))
path = pwd;
else
whatStruct = what(path);
path = whatStruct.path;
end
if (isempty(checkJavaAvailable) ...
&& com.mathworks.mde.editor.EditorOptions.getShowNewFilePrompt == false ...
&& com.mathworks.mde.editor.EditorOptions.getNamedBufferOption == ...
com.mathworks.mde.editor.EditorOptions.NAMEDBUFFER_DONTCREATE ...
&& com.mathworks.mde.editor.EditorOptions.getBuiltinEditor ~= 0)
[errMessage, errID] = showFileNotFound(file, false);
else
openEditor(fullfile(path,fileName));
end
else
[errMessage, errID] = showFileNotFound(file, false);
end
handleError(errMessage, errID);
也许我的edit.m文件有问题?还是某个设置导致新的具有代码的edit.m文件抛出错误?有什么想法吗?
edit
的文件,它掩盖了内置函数。要检查,请运行which edit
。 - slayton