File Exchange

image thumbnail


version (4.09 KB) by Chad English
Similar to waitbar, but with estimated time remaining and progress percentage.


Updated 12 Mar 2002

View License

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.

Cite As

Chad English (2021). timebar (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (16)

Raz Shimoni

Very useful.

Francesco Montorsi

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 :)


Michael St.

Good Work.
To speed up code by factor ~50:

comment line 137: pause(10e-100)
go after line 139: h=message;
insert: figure(h);


Nice. It is exactly the function that I am looking for. Thanks.

John D'Errico

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.

Christal Hu

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!

Metin S

Works great.. Only 3 lines of code to get it to work..

nadia a

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 :)

shoa jakson

better than waitebar

Ali Ozgun Ok

Nice bar!!! thanks...

Ryan O'Hara

This bar is discernible decrease in computuational speed was really seen. Now I know whether to go get a cup of coffee or got to lunch!

Rogério Paulo Rodrigues

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.

Lei Wang

Very useful. It can show both time and progress information!

Fabio Murra

The bar is pretty neat but it slows calculations incredibly even at very small update rates

Christian Ribe

Nice just what i was looking for!
Thanks Chad.

MATLAB Release Compatibility
Created with R12
Compatible with any release
Platform Compatibility
Windows macOS Linux


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!