Documentation

ExitMATLAB

Ways to Exit

At any time, do one of the following:

  • Click the Close boxin the MATLAB®desktop.

  • Click左边的桌面标题栏和希利ctClose.

  • Typequitorexitat the command prompt.

MATLAB closes after:

Confirm Exiting

To set a preference that displays a confirmation dialog box when you exit:

  1. On theHometab, in theEnvironmentsection, clickPreferences.

  2. SelectMATLAB>General>Confirmation Dialogs.

  3. 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.mscript, as described in the following section.

Running a Script When Exiting

When MATLAB exits, it runs the scriptfinish.m, iffinish.mexists in the current folder or anywhere on the search path. You create the filefinish.mcontaining statements such as saving the workspace or displaying a confirmation dialog box. There are two sample files inmatlabroot/toolbox/localthat you can use as the basis for your ownfinish.mfile:

  • finishsav.m— Includes asavefunction 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

Was this topic helpful?