edit - Edit or create file - MATLAB (original) (raw)
Main Content
Syntax
Description
edit
opens a new file called Untitled.m
in the Editor. MATLABĀ® does not automatically save Untitled.m
.
edit [file](#btk4bs6-file)
opens the specified file in the Editor. Iffile
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 createfile
. Otherwise, MATLAB ignores the argument.
You must specify the extension to open .mdl
files. Editing MAT-files and binary files such as P-code files and MEX-files is not supported using theedit
function.
edit [file](#btk4bs6-file)1 ... [file](#btk4bs6-file)N
opens each file, file1 ... fileN
, in the Editor.
Examples
Create and open a new file titled Untitled.m
in the MATLABĀ® Editor (or default editor). Untitled.m
does not appear in your Current Folder.
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 create new_script.m
. Click Yes to create and open tests/new_script.m
.
mkdir tests edit tests/new_script.m
Create a second file using a string. Click Yes to create and open tests/new_script2.m
.
S = "tests/new_script2.m"; edit(S)
Create and open the files file1
, file2
, file3
, and file4
in sequence.
edit file1 file2 file3 file4
Input Arguments
File name, specified as a character vector or string. Iffile
specifies 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 find file
, thenedit
creates a file with the specified name and a.m
extension.
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:
If the file is part of a class or namespace, then either specify the path and extension or separate the components of the name with periods, such as:
edit className.name edit namespaceName.name edit namespaceName.className.name edit namespaceName.name
Data Types: char
| string
Version History
Introduced before R2006a