Syntax
io=figureisopen
Output Parameter
Examples
close all; figureisopen
gcfSG
Copyright 2022-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, figureisopen
, determines if there is an open graphics window in MATLAB. It is part of the SolidGeometry library and was introduced in version 5.1.
Input Parameters
The function does not take any input parameters.
Output
io
: A boolean value indicating if a graphics window is open. Returns true
if a window is open, otherwise false
.
Algorithm Explanation
The function uses the following steps to determine if a graphics window is open:
- It calls
get(groot, 'Children')
to retrieve the list of all open figure windows.
- It checks if this list is empty using
isempty
.
- The result is negated with
~
to set io
to true
if there are any open figures, and false
otherwise.
Additional Code Comments
The commented-out code suggests an alternative method to determine if a figure is open by comparing the positions of two figures:
- Create a new figure
b
and compare its position with the current figure a
.
- If their positions are not equal, it implies that a figure is open.
- Close the newly created figure
b
.
- If no figure was open initially, close the current figure
a
.
Algorithm explaination created using ChatGPT on 2025-08-18 22:53. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21