5.0

5.0 | 4 ratings Rate this file 162 downloads (last 30 days) File Size: 3.33 KB File ID: #22161

waitbar with time estimation

by Andrew

 

19 Nov 2008 (Updated 09 Jun 2009)

Code covered by BSD License  

Estimated remaining, elapsed time, and percentage complete.

Download Now | Watch this File

File Information
Description

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)
Zip File Content  
Other Files license.txt,
waitbar.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (8)
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;
becomes
line 45: h = message; message = [];

And, in the subfunction updatewaitbar:
line 143: set(hh.message,'String',message);
becomes
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!

24 Feb 2009 William Henry Brave

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

26 Feb 2009 Arturo Serrano  
28 Feb 2009 skouliki katelouzos

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...');
k=0;
tic
for i=1:1000,
    k=k+1;
waitbar(i/1000);
end
toc
k=0;
tic
for i=1:1000,
    k=k+1;
end
toc
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

02 Mar 2009 Ross Hatton

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.

04 Mar 2009 skouliki katelouzos

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.

07 Apr 2009 csb

try this to speed up things

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

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');
        else
            r_mes = ('--:--:--');
        end

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

Please login to add a comment or rating.
Updates
12 Dec 2008

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

26 Feb 2009

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

09 Jun 2009

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

Tag Activity for this File
Tag Applied By Date/Time
waitbar Andrew 19 Nov 2008 14:08:58
estimated time remaining Andrew 19 Nov 2008 14:08:58
elapsed time Andrew 19 Nov 2008 14:08:58
elapsed time Teunis 30 Jul 2009 05:06:01
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com