Desktop Tools and Development Environment |
Saving M-Files
After making changes to an M-file, you see an asterisk (*) next to the filename in the title bar of the Editor/Debugger. This indicates there are unsaved changes to the file.
To save the changes, use one of the Save commands in the File menu:
.m
extension to the filename. If you do not want an extension, type a .
(period) after the filename.
You cannot save a file while in debug mode. If you try to, MATLAB displays a dialog box asking if you want to exit debug mode and then save the file. While debugging, you can execute sections of an M-file even though there are unsaved changes--see Running Sections in M-Files That Have Unsaved Changes.
Note
Save any M-files you create and any M-files from The MathWorks that you edit in a directory that is not in the $matlabroot/toolbox directory tree. If you keep your files in $matlabroot/toolbox directories, they can be overwritten when you install a new version of MATLAB. Also note that locations of files in the $matlabroot/toolbox directory tree are loaded and cached in memory at the beginning of each MATLAB session to improve performance. If you save files to $matlabroot/toolbox directories using an external editor or add or remove files from these directories using file system operations, run rehash toolbox before you use the files in the current session. If you make changes to existing files in $matlabroot/toolbox directories using an external editor, run clear functionname before you use the files in the current session. For more information, see rehash or Toolbox Path Caching in MATLAB. |
As you make changes to a file in the Editor/Debugger, every five minutes the Editor/Debugger automatically saves a copy of the file to a file of the same name but with an .asv
extension. The autosave copy is useful if you have system problems and lose changes made to your file. In that event, you can open the autosave version, filename.asv
, and then save it as filename.m
to use the last good version of filename
. For example, if you edit filename.m
and do not save it for five minutes, MATLAB saves the file including the unsaved changes, to filename.asv
.
Use autosave preferences to turn the autosave feature off or on, to specify the number of minutes between automatic saves, and to specify the file extension and location for autosave files. For details, see Autosave Preferences for the Editor/Debugger in the online documentation."
If the file you are editing is in a read-only directory and the autosave preference for location is the source file directory, an autosave copy of the file is not made.
Deleting Autosave Files. By default, autosave files are not automatically deleted when you delete the source file. To keep autosave to M-file relationships clear and current, it is a good practice when you rename or remove an M-file to delete or rename its corresponding autosave file.
There is a preference to Automatically delete autosave files. With this preference selected, when you close an M-file in the Editor/Debugger, MATLAB automatically deletes the corresponding autosave file.
Accessing Your Source Control System
If you use a source control system for M-files, you can access it from within the Editor/Debugger using File -> Source Control. For more information, see Source Control Interface.
Opening a Selection in an M-File | Running M-Files from the Editor/Debugger |
© 1994-2005 The MathWorks, Inc.