Main Content

finish

User-defined termination script forMATLAB

Syntax

Description

example

finishexecutes user-specified commands when exiting. MATLAB®calls thefinish.mscript, if defined, whenever you do one of the following.

  • 单击关闭按钮on the MATLAB desktop on Microsoft®Windows®platforms or the equivalent on UNIX®platforms.

  • Typequitorexitat the command prompt.

If an error occurs in thefinishscript, thenquitis canceled so that you can correct yourfinish.mfile without losing your workspace.

Examples

collapse all

Use the MATLAB sample filefinishsav.mto save the workspace to a MAT-file when MATLAB quits.

To view the contents or edit the file, open thefinishsav.mfile in the editor.

edit(fullfile(matlabroot,'toolbox','local','finishsav.m'));

Copy the file to the search path and rename it tofinish.m.

copyfile(fullfile(matlabroot,'toolbox','local','finishsav.m'),fullfile(userpath,'finish.m'))

Use the MATLAB sample filefinishdlg.mto display a custom dialog box allowing you to cancel when MATLAB quits.

To view the contents or edit the file, open thefinishdlg.mfile in the editor.

edit(fullfile(matlabroot,'toolbox','local','finishdlg.m'));

Copy the file to the search path and rename it tofinish.m.

copyfile(fullfile(matlabroot,'toolbox','local','finishdlg.m'),fullfile(userpath,'finish.m'))

To display this confirmation dialog box, set theConfirm before exiting MATLABoption inGeneral Preferences.

Tips

See Also

||

Topics

Introduced before R2006a