To open an existing file or files in the Editor, choose the option that achieves your goals, as described in this table.
Goal | Steps | Additional Information |
---|---|---|
Open with associated tool Open a file using the appropriate MATLAB® tool for the file type. | On the Editor, Live
Editor, or Home tab, in the
File section, click You also can double-click the file in the Current Folder browser. | For example, this option opens a file with a
|
Open as text file Open a file in the Editor as a text file, even if the file type is associated with another application or tool. | On the Editor tab, in the
File section, click
Open
| This is useful, for example, if you have imported a
tab-delimited data file ( |
Open function from within file Open a local function or function file from within a file in the Editor. | Position the cursor on the name within the open file, and
then right-click and select Open
| You also can use this method to open a variable or Simulink® model. For details, see Open a File or Variable from Within a File. |
Reopen file Reopen a recently used file. | At the bottom of the Open
| To change the number of files on the list, click |
Reopen files at startup At startup, automatically open the files that were open when the previous MATLAB session ended. | On the Home tab, in the
Environment section, click
| |
Open file displaying in another tool Open a file name displaying in another MATLAB desktop tool or Microsoft® tool. | Drag the file from the other tool into the Editor. | For example, drag files from the Current Folder browser or from Windows® Explorer. |
Open file using a function | Use the edit or open
function. | For example, type the following to open
edit collatz.m If
|
For special considerations on the Macintosh platform, see Navigating Within the MATLAB Root Folder on macOS Platforms.
Some options for opening files are not available in MATLAB Online™.
After you modify a file in the Editor, an asterisk (*) follows the file name. This asterisk indicates that there are unsaved changes to the file.
You can perform four different types of save operations, which have various effects, as described in this table.
Save Option | Steps |
---|---|
Save file to disk and keep file open in the Editor. | On the Editor or Live
Editor tab, in the File
section, click |
Rename file, save it to disk, and make it the active Editor document. Original file remains unchanged on disk. |
|
Save file to disk under new name. Original file remains open and unsaved. |
|
Save changes to all open files using current file names. All files remain open. | On the Editor tab, in the
File section, click
Save
|
Some options for saving files are not available in MATLAB Online.
MathWorks® recommends that you save files you create and files from
MathWorks that you edit to a folder that is not in the
matlabroot
folder tree, where
matlabroot
is the folder returned when you type
matlabroot
in the Command Window. If you keep your files
in matlabroot
folders, they can be overwritten when
you install a new version of MATLAB software.
At the beginning of each MATLAB session, MATLAB loads and caches in memory the locations of files in the
matlabroot
folder tree. Therefore, if you:
Save files to matlabroot
folders using
an external editor, run rehash
toolbox
before you
use the files in the current session.
Add or remove files from matlabroot
folders using file system operations, run rehash
toolbox
before you
use the files in the current session.
Modify existing files in matlabroot
folders using an external editor, run clear
function-name
before you use these files
in the current session.
For more information, see rehash
or Toolbox Path Caching in MATLAB.
When you modify a file in the Editor, the Editor saves a copy of the file
using the same file name but with an .asv
extension every 5
minutes. The backup version is useful if you have system problems and lose
changes you made to your file. In that event, you can open the backup version,
filename.asv
, and then save it as
filename.m
to use the last good version of
filename
.
Note
The Live Editor and MATLAB Online do not automatically save copies of files.
To select preferences, click
Preferences, and then select MATLAB > Editor/Debugger > Backup Files on the Home tab, in the
Environment section. You can then:
Turn the backup feature on or off.
Automatically delete backup files when you close the corresponding source file.
By default, MATLAB automatically deletes backup files when you close the Editor. It is best to keep backup-to-file relationships clear and current. Therefore, when you rename or remove a file, consider deleting or renaming the corresponding backup file.
Specify the number of minutes between backup saves.
Specify the file extension for backup files.
Specify a location for backup files
If you edit a file in a read-only folder and the back up Location preference is Source file directories, then the Editor does not create a backup copy of the file.