close all hidden problem
Show older comments
I want to close the invisible figure in an app, but after I use command: close all hidden, the apps are becomes 'invalid or deleted objects'
close all hidden will only close figures including invisible figures, not apps. so...is there any mistake with my operation?
Thanks!
Yu
8 Comments
Kevin Chng
on 4 Jan 2019
Is there any infinite loop running in your apps?
Yu Li
on 4 Jan 2019
Kevin Chng
on 4 Jan 2019
or try to delete the specific hidden figure in this way:
close(h)
name the figure as h, let see will it working fine or not.
Yu Li
on 4 Jan 2019
Kevin Chng
on 4 Jan 2019
Edited: Kevin Chng
on 4 Jan 2019
Try
figHandles = get(groot, 'Children');
for i=1:1:length(figHandles)
close(figHandles(i));
end
If error is persistent, i believe there is something still running with the figures.
Yu Li
on 4 Jan 2019
"but according to this page: https://www.mathworks.com/help/matlab/ref/close.html close all hidden will only close figures including invisible figures, not apps"
I searched that page for the word "app" and it only occurs once in a link below the help itself. Why do you think that close does not apply to apps? I don't see that written anywhere on that page.
In any case, writing close all is a sledgehammer approach to writing code. While it might be fun and useful from the command line, coding something like that into any app, GUI, or function is like shooting yourself in the knee. Instead of writing such brutal, uncontrolled code, learn how to obtain and use explicit handles for all graphics objects that you use:
Once you learn to use graphics object handles then your code will be much more robust, reliable, and easier to debug.
Yu Li
on 7 Jan 2019
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!