MATLAB Functions Help Desk

close

Purpose

Delete specified Figure

Syntax

Description

close deletes the current Figure or the specified Figure(s). It optionally returns the status of the close operation.

close deletes the current Figure (equivalent to close(gcf)).

close(h) deletes the Figure identified by h. If h is a vector or matrix, close deletes all Figures identified by h.

close name deletes the Figure with the specified name.

close all deletes all Figures whose handles are not hidden.

close all hidden deletes all figures including those with hidden handles.

status = close(...) returns 1 if the specified windows have been deleted and 0 otherwise.

Remarks

The close function works by evaluating the specified Figure's CloseRequestFcn property with the statement:

The default CloseRequestFcn, closereq, deletes the current Figure using delete(get(0,'CurrentFigure')). If you specify multiple Figure handles, close executes each Figure's CloseRequestFcn in turn. If MATLAB encounters an error that terminates the execution of a CloseRequestFcn, the Figure is not deleted. Note that using your computer's window manager (i.e., the Close menu item) also calls the Figure's CloseRequestFcn.

If a Figure's handle is hidden (i.e., the Figure's HandleVisibility property is set to callback or off and the Root ShowHiddenHandle property is set no), you must specify the hidden option when trying to access a Figure using the all option.

To unconditionally delete all Figures, use the statements:

The delete function does not execute the Figure's CloseRequestFcn, it simply deletes the specified Figure.

The Figure CloseRequestFcn allows you to either delay or abort the closing of a Figure once the close function has been issued. For example, you can display a dialog box to see if the user really want to delete the Figure or save and cleanup before closing.

See Also

delete, figure, gcf

The Figure HandleVisibility property

The Root ShowHiddenHandle property



[ Previous | Help Desk | Next ]