TIMEBAR is a progress window, similar to waitbar, that shows the progress of calculations using a sliding bar, a displayed percentage complete, and an estimated time remaining.
The estimated time remaining is calculated linearly using only the initialized time, the current time, and the percent progress. It assumes a constant rate of progress.
The user can also define a displayed message (e.g., to indicate what process is being monitored) as well as a window title.
Chad English (2020). timebar (https://www.mathworks.com/matlabcentral/fileexchange/1255-timebar), MATLAB Central File Exchange. Retrieved .
Very nice function!
Note however there is a typo, at line 29, in the comments containing an example to run, it should be "timebar(h,i/100)" instead of "timebar(h,1/100)", otherwise the progress signaled to the timebar is always 1/100 instead of proceeding toward 100 :)
To speed up code by factor ~50:
comment line 137: pause(10e-100)
go after line 139: h=message;
Nice. It is exactly the function that I am looking for. Thanks.
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.
n = 1000;
s = 0;
for i = 1:n,
s = s + i;
Elapsed time is 0.003069 seconds.
Now put in a timebar.
h = timebar('fgfg','fhhth');
n = 1000;
for i = 1:n,
s = s + i;
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.
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!
Works great.. Only 3 lines of code to get it to work..
This progress bar is great! It really helps improving my GUI. It would be better if there is a Cancel button included in case user attempts to stop the process. Thanks a lot! I'll be using it for my masters research and I'll quote you as the source :)
better than waitebar
Nice bar!!! thanks...
This bar is terrific...no discernible decrease in computuational speed was really seen. Now I know whether to go get a cup of coffee or got to lunch!
Excellent, I use this for large files compilations. It gives you the idea of how much time it still miss and if the computer is blocked or not.
Very useful. It can show both time and progress information!
The bar is pretty neat but it slows calculations incredibly even at very small update rates
Nice just what i was looking for!
Added an update rate option, with a default of 0.1 seconds.