MATLAB: Using waitbar with tic toc..

matlab gui

Hi, I am trying to display waitbar; i have defined tic @ start of the code and the following code @ end:
end_Time = toc;
a=waitbar(1, 'Please wait ..', 'Working');
for k=tic:end_Time;
waitbar(k, a);
end
% close(a)
But the waitbar is not running in a continuous mode, it runs near the end and vanishes. I want its progress to scynchronise with code running time. Thanks alot.

Best Answer

The waitbar is fine in your code, but tic and toc fail.
waitH = waitbar(1, 'Please wait ..');
for k = 1 : 10
waitbar(k / 10, waitH);
pause(0.5)
end
delete(waitH )
Related Question