I've tried it a few times. Nice help. I like the time remaining counter. It works nicely, but with a flaw. You don't realize how much time is being used by the timebar updates. Do a simple comparison. Here I'll write a loop that does nothing but sum the integers from 1 to 1000. It should run VERY quickly.
tic
n = 1000;
s = 0;
for i = 1:n,
s = s + i;
end
toc
Elapsed time is 0.003069 seconds.
Now put in a timebar.
tic
h = timebar('fgfg','fhhth');
n = 1000;
for i = 1:n,
timebar(h,i/n,.1)
s = s + i;
end
close(h)
toc
Elapsed time is 1.344795 seconds.
See that with a timebar generated, it took a loop that should terminate in virtually NO time at all, and wasted 99.8% of the time just to do a timebar.
So be careful if you have a really big loop, with hugely many iterations. You might be surprised at how much more quickly it will run without any timebar at all. The place to use this code is when you have a loop where each pass through the loop is intensive, but with perhaps at most a few hundred iterations of the loop. Otherwise you will be disappointed.
13 May 2008
timebar
Similar to waitbar, but with estimated time remaining and progress percentage.
Author: Chad English
Hu, Christal
Hi, may i know how to integrate this bar into GUI which does audio file playing? I'm thinking of knowing how much time elapsed n progress in the audio file, similiar to window media player. Thank you!