How do I reopen a closed figure with a pre-allocated figure handle from Matlab 2014b onwards?

18 次查看(过去 30 天)
I have pre-allocated my figures such that I generate an empty figure window without a plot which is assigned to a figure handle at the start of a script. I then close these figures as I don't require they all be opened or remain open all at once. I want to reopen these figures one by one at appropriate times, but it appears that upon closing a figure by its assigned/allocated handle within Matlab 2014b and onwards, the assigned figure handle empties itself of all information related to the figure. I understand that the nature of the figure handle has changed to an object now and I need to utilise the figure.Number property to access it's assigned integer.
h = figure; % Pre-allocate figure handle. Generates figure object in Matlab 2014b and onwards.
close(h); % Close pre-allocated figure.
figure(h.Number); % Re-open figure.
This produces the following error.
Invalid or deleted object.
How do I reopen a closed figure in Matlab 2014b and onwards?

采纳的回答

Walter Roberson
Walter Roberson 2016-4-1
h.Number becomes invalid once you close the figure. You would need to record the number before closing.
In all versions of MATLAB including before R2014b, there was no such thing as reopening a figure: there was just creating a new figure that had the same figure number. When you close a figure the behavior has always been that the associated structure is destroyed.
If you want to reopen a figure then you should be thinking in terms of making the figure visible off while you do not need the figure showing, and then adjusting properties and setting visible on when you need the figure.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by