Matlab will not create files using the edit command

When i enter

edit somenewfile.m 

in my Matlab R2010a command window it gives me this error

 ??? Error using ==> edit at 57 Neither 'somenewfile' nor 'somenewfile.m' could be found. 

On my other computer with R2012a at work, this same command works and creates a new file. Is there anything else in 2010?

I tried a little to play with edit.m, but I'm afraid that I messed up something. Here is the part he fails in

 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 

in ShowEmptyFile looks like

 %-------------------------------------------------------------------------- % 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, ie foo.m) % OR % 2) the given file directory portion exists (note that to get into % this method it is implied that the file portion does not exist) % (ie 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); 

Maybe I have a bad .m editor? Or Was there a parameter that called a new edit.m with code to throw an error? Any ideas?

+4
source share
1 answer

I get the same error message in 2010a (line 57 edit.m) if I edit a nonexistent file after unchecking the following option:

File β†’ Settings β†’ General β†’ Confirmation Dialogs β†’ Hint when editing files that do not exist

Given this, it looks like you do not have this option?

+3
source

Source: https://habr.com/ru/post/1434959/


All Articles