Matlab App designer - use 'close all' without deleting GUI

32 views (last 30 days)
Hi All
A quick one but one I am having issues with. Currently I am developing a GUI which has several quite complex image processing functions within it that are activated via buttons etc within the GUI. The current issue I have is that many of these scripts currnetly use a
close all
command to clear all their handles and created figures upon finishing. The issue I am finding now is that this also closes the GUI window as well which is not what I want!
Is there an alternative way of doing this in which I can close the handles etc within the functions without closing the GUI windown itself. I have tried commenting out the 'close all' statements within the functions but this made them very buggy so I need to find a way of clearing them if at all possible....
Any answers much appreciated!

Accepted Answer

Rik
Rik on 25 Mar 2019
You can use handles returned on the opening the figure to close them:
f=figure;
%some interaction with the figure
plot(rand(2,10))
%another figure
f(2)=figure;
bar(1:4);
%close the specific figures (works with an array of handles)
close(f)
  3 Comments
Rik
Rik on 27 Mar 2019
Glad to be of help.
As to your new problem, it might be caused by a number of things. Is your code using an ActiveX server, or the normal xlswrite tool? Does quiting the process (through taks manager) and then running it as function work?
In file IO there shouldn't really be a difference between functions and scripts.
dweather
dweather on 29 Mar 2019
Yes, I was very confused about this too, it's xlswrite and I've used it in other functions called by the GUI without issue.
I've ended up using a !kill at the allifcted part of the script, and that seems to have fixed it (although I appreciate it's a bit of a fudge!).
Thanks for your help though!

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 29 Mar 2019

Community Treasure Hunt

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

Start Hunting!