This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Edit or create file




edit opens a new file called Untitled.m in the Editor. MATLAB® does not automatically save Untitled.m.


edit file opens the specified file in the Editor. If file does not already exist, MATLAB asks if you want to create it. file can include a partial path, complete path, relative path, or no path. If file includes a partial path or no path, edit will look for the file on the search path. You must have write permission to the path to create file, otherwise, MATLAB ignores the argument.

You must specify the extension to open .mlx, .mat and .mdl files. MATLAB cannot directly edit binary files, such as .p and .mex files.


edit file1 ... fileN opens each file, file1 ... fileN, in the Editor.


collapse all

Open a New File


A new file titled Untitled.m opens in the MATLAB Editor (or default editor). Untitled.m does not appear in your Current Folder.

Create a New File

mkdir tests
edit tests/new_script.m

A dialog box appears, asking if you want to create new_script.m. If you select Yes, MATLAB creates and opens tests/new_script.m.

Open Files

edit file1 file2 file3 file4

MATLAB sequentially creates and opens the files: file1, file2, file3, and file4 in sequence.

Input Arguments

collapse all

file — Name of filestring

Name of file, specified as a string. If file specifies a path that contains a nonexistent folder, MATLAB throws an error. Specify multiple files on the same line by separating filenames with a space.

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

edit folderName/file

If you do not specify the extension, then edit opens a file with the specified name and a .m extension.

edit name

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:


Data Types: char

See Also


Introduced before R2006a

Was this topic helpful?