View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
waitbar with time estimation

4.9 | 12 ratings Rate this file 81 Downloads (last 30 days) File Size: 3.33 KB File ID: #22161 Version: 1.5
image thumbnail

waitbar with time estimation


Andrew (view profile)


19 Nov 2008 (Updated )

Estimated remaining, elapsed time, and percentage complete.

| Watch this File

File Information

This version of waitbar is compatible with MATLAB's version. Thus, doesn't require any modification of existing functions using the waitbar. However, the property settings include with MATLAB's version will not be recognized.

This program is a heavily modified version of timebar.m by Chad English.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (16)
20 Oct 2016 SMK

SMK (view profile)

Loved it. great work.

03 Sep 2015 Dvir

Dvir (view profile)

08 Jan 2015 WurmD

WurmD (view profile)

Heya, loved it! ^_^

Works seamlessly with my old code.

Just ran into one hiccup in my work PC, sometimes it hangs in this line:

h = buildwaitbar(X,message);

my solution, just a try catch and re-try:

h = buildwaitbar(X,message);
catch me
warning([me.message '. Retrying...'])
h = buildwaitbar(X,message);

30 Jun 2014 Ivan

Ivan (view profile)

19 Dec 2013 Lukas Lansky

Works nicely.

24 Jun 2013 Preetham Manjunatha

Awesome work! Great share, keep that up.

12 Feb 2013 Fran├žois Beauducel

Great job. Thanks.
A little improvement for compatibility: in Matlab's original waitbar, the 'message' string is optional for the first call:
With your function it makes an error.

26 Jan 2010 Rob Campbell

Rob Campbell (view profile)

Like the Mathworks waitbar but better! Very useful for loops in which each iteration takes a long time. There are solutions for loops with quick iterations so the above critique is somewhat harsh.

22 Jun 2009 Philipp Pruefer

Great tool! The only prob I had was dealing with zero progress. My solution is:

% 2.2 - Calculate the estimated time remaining
e_mes = datestr(elap/86400,'HH:MM:SS');
if progress~=0
sec_remain = elap*(1/progress-1);
r_mes = datestr(sec_remain/86400,'HH:MM:SS');
r_mes = ('--:--:--');

Not sure why I had the prob only after a fresh start of Matlab though...

07 Apr 2009 csb

csb (view profile)

try this to speed up things

% pause(10e-120) % Needed for window to appear (do not know why)

Comment only
04 Mar 2009 NeuralDip

Ross, i don't want to argue much on this, i see your point.
I mean you have a point if the computation is heavy due to what's inside the loop, but not when is due to the high number of iterations.

Comment only
02 Mar 2009 Ross Hatton

Ross Hatton (view profile)

In response to the time comparison:

Updating the graphical progress display is certainly going to take longer than an addition operation like k=k+1, but will be negligible when compared to a computationally heavy process, and can be read from across the room.

Comment only
28 Feb 2009 NeuralDip

ok, cool looking, but this whole waitbar thing is not very useful.
the point is that updating graphics in Matlab is very time consuming.look at this:

h = waitbar(0,'Please wait...');
for i=1:1000,
for i=1:1000,
Elapsed time is 15.628354 seconds.
Elapsed time is 0.003811 seconds.

If you have a loop that takes enough time to make reasonable the use of a timebar, then using the timebar will make the computation 4000 times slower.
Updating only test is much more efficient, so i like going for a running percentage thing.
The timebar is good looking though

Comment only
26 Feb 2009 Arturo Serrano

Arturo Serrano (view profile)

24 Feb 2009 William Henry Brave

Great contribution, works seamlessly without any modification of the code, thanks...

08 Feb 2009 Anthony Kendall

Very nice, though there is one bug that shows up in the provided example: the message is overwritten with the graphics handle

A fix I used is:
line 45: h = message;
line 45: h = message; message = [];

And, in the subfunction updatewaitbar:
line 143: set(hh.message,'String',message);
line 145: if ~isempty(message),set(hh.message,'String',message);end

Otherwise, it works great and is a complete drop-in replacement for waitbar. Thanks!

12 Dec 2008 1.2

Fixed problem of comparability with existing MATLAB's waitbar.m.

26 Feb 2009 1.3

I believe I fixed the bug mentioned in the comments, please contact me if any problems are encountered.

09 Jun 2009 1.4

As suggested in the comment, I changed the pause(10e-120) to drawnow. Thanks for that tip, there is always something to learn.

23 Jan 2010 1.5

I fixed a problem with updating messages.

Contact us