close
Closes figure windows.
Category: Data Import and Analysis > Data Import and Export
Syntax
close
Closes the current figure.
close(fig)
Closes the figure with handle fig.
close all
Closes every open figure.
Description
A closed figure's handle becomes invalid, which isvalid reports as false. Closing a figure that is not open does nothing. Use close all at the top of a script to start from a clean slate.
Input arguments
fig- Figure handle or figure number.
Example
Close one figure, then all
f1 = figure('Visible', 'off');
f2 = figure('Visible', 'off');
close(f1);
[isvalid(f1) isvalid(f2)]
close all
[isvalid(f1) isvalid(f2)]
Output
ans = 1×2 logical array
0 1
ans = 1×2 logical array
0 0