4

入ると

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がエラーをスローする原因となった設定がありましたか?何か案は?

4

1 に答える 1

3

次のオプションのチェックを外した後に存在しないファイルを編集すると、2010a(edit.mの57行目)で同じエラーメッセージが表示されます。

[ファイル]->[設定]->[一般]->[確認ダイアログ]->存在しないファイルを編集するときにプロンプ​​トを表示する

それを念頭に置いて、あなたはそのオプションを有効にしていないように聞こえますか?

于 2012-09-19T10:07:16.200 に答える