[EDIT: Thu May 26 18:36:12 UTC 2011 – Reformat – MKF]
Hi all,
I'm trying to use a waitbar to make my function a bit more user friendly.
It works as I intend it to, except for the fact that I cannot close the waitbar window after the function is done executing, or if I cancell the process half way through. I actually have to "quit force" to shut matlab down to close get rid of the waitbar window.
Bellow is an example of how I create the waitbar. Could somebody suggest what could be causing the problem?
==================================================
%estimate length of time of computation
%time for first loop:
time1=10;%time for second loop:
time2=20;%total time:
total_time=time1+time2;%create a waitbar
h.waitbar=waitbar(0,'Importing and processing data...','Name','Progress',... 'CreateCancelBtn',... 'setappdata(gcbf,''canceling'',1)');setappdata(h.waitbar,'canceling',0)%first loop:
for step=1:stepswaitbar(step/steps*time1/total_time)end%update waitbar message
waitbar(time1/total_time,h.waitbar,'Generating the animation...');%second loop:
for step=1:stepswaitbar(time1/total_time+step/steps*time2/total_time,h.waitbar)end%close the waitbar
close(h.waitbar);
==================================================
Best Answer