close
Close one or more figures
Description
close
closes the current figure. Calling close
is equivalent to calling close(gcf)
.
close all
closes all figures whose handles are visible. A figure
handle is hidden if the HandleVisibility
property is
set to 'callback'
or 'off'
.
close all hidden
closes all figures, including figures with hidden
handles.
close all force
closes all figures, including figures for which the
CloseRequestFcn
callback has
been specified to prevent users from closing the figure window.
status = close(___)
returns the
status
of the close operation for any of the previous syntaxes. The
function returns 1
if the figure or figures close and
0
otherwise. When specifying the output status
, you
must enclose input arguments that are character vectors in parentheses; for example,
status = close('all','hidden')
.
Examples
Input Arguments
Tips
To delete all figures unconditionally, use these statements:
set(groot,'ShowHiddenHandles','on') c = get(groot,'Children'); delete(c)
When implementing a
CloseRequestFcn
callback, do not use a call toclose
. Callingclose
in the body of the callback sets up a recursion that results in a MATLAB warning. Instead, implement the callback using thedelete
function.delete
removes the figure without executing theCloseRequestFcn
callback.If you call
close
on a figure without specifying theCloseRequestFcn
property, the default value of the property,closereq
, unconditionally deletes the figure and closes its window. To prevent deletion when callingclose
, implement aCloseRequestFcn
callback.
Algorithms
The close
function evaluates the CloseRequestFcn
property of the specified figure f
using this statement:
eval(get(f,'CloseRequestFcn'))
CloseRequestFcn
enables you to either delay or abort the closing of a
figure once close
has been invoked. For example, you can display a dialog
box to confirm that the user really wants to close the figure or save and clean up before
closing.
The default value of CloseRequestFcn
, closereq
,
closes the current figure using delete(get(groot,'CurrentFigure'))
. If you
specify an array of figure handles, close
executes the callback specified
by CloseRequestFcn
for each figure.
If an error terminates the execution of a CloseRequestFcn
callback,
then the figure is not closed.
Version History
Introduced before R2006a