ExitMATLAB
Ways to Exit
At any time, do one of the following:
Click the Close box
in the MATLAB®desktop.
Click
左边的桌面标题栏和希利ctClose.
Type
quit
orexit
at the command prompt.
MATLAB closes after:
Prompting you toconfirm exiting, if that preference is specified.
Prompting you to save any unsaved files
Running a script when exiting, if the
finish.m
script exists in the current folder or on the search path.
Confirm Exiting
To set a preference that displays a confirmation dialog box when you exit:
On theHometab, in theEnvironmentsection, click
Preferences.
SelectMATLAB>General>Confirmation Dialogs.
Select theConfirm before exiting MATLABcheck box and clickOK.
MATLAB then displays the following dialog box when you exit.
You can also display your own exit confirmation dialog box using afinish.m
script, as described in the following section.
Running a Script When Exiting
When MATLAB exits, it runs the scriptfinish.m
, iffinish.m
exists in the current folder or anywhere on the search path. You create the filefinish.m
containing statements such as saving the workspace or displaying a confirmation dialog box. There are two sample files inmatlabroot
/toolbox/local
that you can use as the basis for your ownfinish.m
file:
finishsav.m
— Includes asave
function so the workspace is saved to a MAT-file.finishdlg.m
— Displays a confirmation dialog box that allows you to cancel quitting.
See Also
Related Topics
- Confirmation Dialog Boxes Preferences
- Recovering Data After Abnormal Termination
- Error Log Reporting
- Troubleshooting Installation(Installation, Licensing, and Activation)