Main Content

edit

Edit or create file

Description

example

editopens a new file calledUntitled.min the Editor. MATLAB®does not automatically saveUntitled.m.

example

editfileopens the specified file in the Editor. Iffiledoes not already exist, MATLAB asks if you want to create it.filecan include a partial path, complete path, relative path, or no path. Iffileincludes a partial path or no path,editwill look for the file on the search path. You must have write permission to the path to createfile. Otherwise, MATLAB ignores the argument.

You must specify the extension to open.matand.mdlfiles. MATLAB cannot directly edit binary files, such as每分钟and.mexfiles.

example

editfile1 ...fileNopens each file,file1 ... fileN, in the Editor.

Examples

collapse all

Create and open a new file titledUntitled.min the MATLAB® Editor (or default editor).Untitled.mdoes not appear in your Current Folder.

edit

Create two new files in a new folder.

Create a file in a new directory using a character vector. A dialog box appears, asking if you want to createnew_script.m. ClickYesto create and opentests/new_script.m.

mkdirtestsedittests/new_script.m

Create a second file using a string. ClickYesto create and opentests/new_script2.m.

S ="tests/new_script2.m"; edit(S)

Create and open the filesfile1,file2,file3, andfile4in sequence.

editfile1file2file3file4

Input Arguments

collapse all

Name of file, specified as a character vector or string. Iffilespecifies a path that contains a nonexistent folder, MATLAB throws an error. Specify multiple files on the same line by separating file names with a space.

If you do not specify the extension and MATLAB is unable to findfile, theneditcreates a file with the specified name and a.mextension.

Iffileis overloaded (that is, appears in multiple folders on the search path), then include a partial path to edit the correct page, such as:

editfolderName/file

If the file is part of a class or package, then either specify the path and extension or separate the components of the name with periods, such as:

editclassName.nameeditpackageName.nameeditpackageName.className.nameeditpackageName.name

Data Types:char|string

Version History

Introduced before R2006a