Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

finish

Termination file for MATLAB program

Description

When the MATLAB® program quits, it runs a script called finish.m, if the script exists and is on the search path MATLAB uses or in the current folder. finish.m is a file you create that instructs MATLAB to perform any final tasks before terminating. For example, you can save the data in your workspace to a MAT-file.

finish.m is invoked whenever you do one of the following:

  • Click the Close box in the MATLAB desktop on Microsoft® Windows® platforms or the equivalent on UNIX® platforms

  • Type quit or exit at the command prompt

Examples

Two sample termination files are provided with MATLAB in matlabroot/toolbox/local.

  • finishsav.m — Saves the workspace to a MAT-file when MATLAB quits.

  • finishdlg.m — Displays a dialog box allowing you to cancel quitting and saves the workspace. See also the Confirmation Dialog Boxes Preferences and the option for exiting MATLAB.

To create a termination file, make a copy of one of these sample files and change the name to finish.m. Make sure that the file is on the MATLAB path. You can modify the file to include any operations you want the termination file to perform.

More About

collapse all

Tips

When using graphics features in finish.m, use uiwait, waitfor, or drawnow so that figures are visible.

See Also

| |

Introduced before R2006a

Was this topic helpful?