How to close a figure and make the rest of the code run?
6 views (last 30 days)
Hello everyone, I think I have an easy question but I don't know exactly how to execute it.
My code starts executing a GUI which opens a Figure where I have to visualize certain images. I want that when I finish my visualization and close this Figure (GUI), the rest of my code continues.
I think it should be something like:
while Figure isopen
or am I wrong?
Thank you so much for your help!
More Answers (1)
Image Analyst on 28 Nov 2015
Get the handle when you create the figure, then use a prompt to let the user know that s/he's ready to continue:
hFig = figure();
% Code to throw stuff up on the figure...
% Wait for user to say they're ready to continue:
promptMessage = sprintf('Do you want to Continue processing,\nor Quit processing?');
titleBarCaption = 'Continue?';
buttonText = questdlg(promptMessage, titleBarCaption, 'Continue', 'Quit', 'Continue');
if strcmpi(buttonText, 'Quit')
return; % Bail out of program - call close(hFig) if you also want to close the figure, otherwise it leaves it up.
% Now continuing on with the program...
% Let's close the figure.