I am using a waitbar like this:
h = waitbar(0,'Please wait...');
for i=1:100, % computation here %
waitbar(i/100)
% other operation here
end
close(h)
I would like to stop this script if the user close the waitbar (clicks the X of the window), without having to add a Cancel button.
Is there any way to do it?
You can test whether
his a valid handle, and exit the loop otherwise. Insert the following into your loop: