Code covered by the BSD License  

Highlights from
progressbar

4.89189

4.9 | 41 ratings Rate this file 161 Downloads (last 30 days) File Size: 4.65 KB File ID: #6922
image thumbnail

progressbar

by Steve Hoelzer

 

15 Feb 2005 (Updated 08 Oct 2010)

Simple, efficient, and user friendly replacement for waitbar.

| Watch this File

File Information
Description

This implementation of progressbar is intended to be extremely simple to use while providing a high quality user experience.

Features:
  - Can add progressbar to existing m-files with a single line of code.
  - Supports multiple bars in one figure to show progress of nested loops.
  - Optional labels on bars.
  - Figure closes automatically when task is complete.
  - Only one figure can exist so old figures don't clutter the desktop.
  - Remaining time estimate is accurate even if the figure gets closed.
  - Minimal execution time. Won't slow down code.
  - Randomized color. When a programmer gets bored...

Demo:
  n = 1000;
  progressbar % Create figure and set starting time
  for i = 1:n
      pause(0.01) % Do something important
      progressbar(i/n) % Update figure
  end

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
progbar
This submission has inspired the following:
txtprogressbar, WORKBAR, Movie Editor, Wilcoxon signed rank examination, Hyperspectral Image Index Analysis

MATLAB release MATLAB 7.10 (2010a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (55)
16 Feb 2005 Alan Brooks

Very simple to use and very efficient. I like the ability to use it in one line of code.

17 Feb 2005 jiro d

very slick!

22 Feb 2005 Antoni Josep Canós Marín

Very good!!. It should be included in future releases of MATLAB.

11 Mar 2005 Tim Faughn

Fantastic!

05 Apr 2005 Ryan Scheppele

Nifty little routine!

15 Jun 2005 Fred Plourde

Very simple and yet, very efficient ! It took me less than 2 minutes to add it successfully to my project

19 Aug 2005 Jean-Vincent LE LAN  
15 Sep 2005 Michal Mackiewicz  
27 Sep 2005 Wolfgang Garn

An interesting extension would be to start more than one progressbars.

06 Oct 2005 Liz Leibman

Thank you! Its just perfect! Now my program looks so good!

11 Nov 2005 Wolfgang Garn

It is really terrific. Thank you.
If you like to have two, three or more progressbars, just copy the m-file to progressbar2, progressbar3, ...

06 Dec 2005 Bharat Rangan

Great work. Very useful little piece. A possible addition is the ability to add another string during inititation which could specify the task at hand. Just my 0.02. Thanks a ton

05 Jan 2006 Suhas Gajre

One of the beautiful codes I have seen!

Very much useful for programmers like me who have to wait for agonizingly long time to finish the code :))

11 Feb 2006 Tom Nagel

I love it. So easy, so helpful.

27 Apr 2006 Dave Douglas

This thing is simple to use and looks fantastic. Thanks!!!

02 Jul 2006 Luis Aponte

This function is great and very simple to use.

07 Aug 2006 Quintin Coetzee

Thak you for this substitute for waitbar.
I will be using it in software I am developing for my 4th year engineering report.

23 Mar 2007 A L P

Have problem with this function and plotting graph.
This is the error that appear:
>??? Invalid handle object.
>
>Error in ==> progressbar at 202
>set(progpatch,'XData',[0 fractiondone >fractiondone 0])
>
>Error in ==> Untitled at 17
> progressbar(inc/nbpt)

13 Dec 2007 Quan Quach

I made some modifications to this great app and you can find it here. Added an abort functionality and an output parameter so that when the progress bar is closed, you can use the output parameter to break from the for loop.

http://www.blinkdagger.com/matlab/matlab-gui-tutorial-progress-status-bar

19 Apr 2008 Abel Brown

lol, so simple and nice. makes ppl think you're awesome at matlab when they see a progbar :)

like this much better than waitbar!!! Nice work

25 Jun 2008 Khaledov Kh

Needs to name the process bar...

27 Aug 2008 jongchul kim

slsls

24 Jan 2010 Muhammad Muzzamil Luqman

Thanks Steve for this wonderful contribution :)

30 Aug 2010 Naor Movshovitz  
08 Oct 2010 Jveer

fantastic contribution!

09 Oct 2010 James Tursa

Nice! Easy to use. Great submission.

09 Oct 2010 Jveer

any chance of seeing 'pause', 'resume' and 'abort' functionality in future versions?

11 Oct 2010 Steve Hoelzer

Jveer: I've played with adding pause and abort buttons but I was never totally happy with how it turned out. The main problem is that those buttons are unresponsive in the time period between calls to progressbar. You click, and then wait until the next call to progressbar before anything happens. In some of my own code, that could be 10 minutes or a half hour. And sometimes the click isn't captured so you never get the desired behavior at all. So far I've chosen to do without rather than add a half-broken feature.

13 Oct 2010 Light Den

It's just perfect!Thank U !

25 Jan 2011 jon erickson

Beautiful, easy to use. A wonder matlab doesn't include this in their standard distro. Love matlab file exchange. Thanks, Steve!

08 Feb 2011 Sky Sartorius

Quite superior to waitbar. One feature I'd really like to see is the ability to update the progress bar label(s) without resetting the progress bar and timer, letting you inform the user exactly what process or subprocess is taking so long. Excellent job on this very handy function.

01 Mar 2011 Egli Vorfi

Excellent !

Just wanted to know if it's possible to close the bar automatically once it's over.

01 Mar 2011 Steve Hoelzer

Egli: The bar closes automatically when you reach 100%. You can force it to close at any time by calling progressbar(1).

09 Apr 2011 Ayla

I really like your progress bar! Would it be possible to integrate it in a custom GUI created by myself instead of displaying it in a separate window? Thanks!

12 Apr 2011 Steve Hoelzer

Ayla: It will take a little work to put progressbar in your own GUI. You'll have to change how the bar is created so it draws in the right place in your GUI instead of its own figure. Good luck!

14 May 2011 halil sen  
14 May 2011 halil sen  
14 May 2011 halil sen  
14 May 2011 halil sen

sorry about the mess, firefox failure. i wish there were a delete comment button...

anyways, first of all thank you for this efficient, fast, and handy function. i wonder whether it is possible to update the 'Label' of the bars or not. OR is it doable?

cheers

EDIT: also, one last thing as far as I can see, the 'remaining time' calculations only depend on the first bar's runtime but this is sort of misleading. maybe, the way how the remaining time is calculated can be optional (e.g. max/min of the remaining time of all bars or the bar(s) that will be used in calculations may be specified by the user or both options at the same time etc.) nevertheless, stating this calculation fact in the Help would be nice and explanatory.

btw, pardon me if i'm wrong about the way of time calculations.

16 May 2011 Steve Hoelzer

Halil: There is no way to update labels without resetting the whole progress bar. I'd welcome code to implement that feature... :)

You're right about the remaining time calculation. I did it that way because of my concept of what multiple bars represent. I always think of the top bar as progress of the overall task, and other bars as progress of sub tasks. For an example of how I would use it, look at the "Fancy multi bar" demo in the progressbar's comments.

23 May 2011 Daniel Baur

Wow, really great work! Love it and it works like a charm.

For my purposes though, I took the liberty of editing around in your code a bit. What I did:
- Changed from function to class, so multiple instances can be run easily and without interfering with each other.
- Incorporated label changes during execution. The bar_text property can be edited and applies again when the figure updates.
- Made the calculation of the remaining time more accurate by taking the mean of all iterations already done as iteration time.

I could send you my modified file if you'd like to have a look!

26 May 2011 Steve Hoelzer

Daniel: Those sound like interesting features. I'd like see how you did it, so please send your code my way. Thanks!

08 Jun 2011 Brian Katz  
10 Jun 2011 Gianluca

Thanks Steve for this fantastic tool, very simple, handy and efficient.

Is there any way to make it work in parallel computing. I run a simple test just using you "simple bar" example and it does not update the bar under the "spmd" function. Any clue of the reason?

14 Jun 2011 Steve Hoelzer

Gianluca: Thanks for the comments!

I'm not familiar with MATLAB's parallel computing features, so I don't know for sure what's going on. My guess is that you can't update local figures from "workers", so you need to monitor their status somehow and update progressbar locally. Let me know if you figure out how to make it work.

12 Aug 2011 Boris Schauerte  
05 Oct 2011 Matthew Schroeder

Great work! Any word on the ability to update labels during execution without resetting the figure?

06 Oct 2011 Steve Hoelzer

Matthew: Thanks! As for label updates, I'm still waiting for a patch. ;)

12 Oct 2011 Benjamin Bratton  
12 Oct 2011 Benjamin Bratton

This is a great piece of code that I use all the time. I appreciate how well commented the code is.

I made some updates so that the bar(s) can be embedded into a gui. I would be happy to send it your way if you like.

09 Nov 2011 Tom Hissel

Hey Benjamin. Your addition of embedding the progress bar into the GUI seems very interesting. How did you do that? Can you post or mail your file? Id love to see how its done(I didnt manage to do that).

Also Steve, thanks for making this nice tool:)

15 Nov 2011 Y.S.  
07 Dec 2011 Hamid.R Ansary  
11 Jan 2012 Zach  
31 Jan 2012 Dmitry  
Please login to add a comment or rating.
Updates
08 Oct 2010

Major overhaul to support multiple bars and add labels.

08 Oct 2010

Major overhaul to support multiple bars and add labels.

Tag Activity for this File
Tag Applied By Date/Time
gui tools Steve Hoelzer 22 Oct 2008 07:41:12
example Steve Hoelzer 22 Oct 2008 07:41:12
progress Steve Hoelzer 22 Oct 2008 07:41:12
progressbar Steve Hoelzer 22 Oct 2008 07:41:12
wait Steve Hoelzer 22 Oct 2008 07:41:12
waitbar Steve Hoelzer 22 Oct 2008 07:41:12
bar Steve Hoelzer 22 Oct 2008 07:41:12
indicator Steve Hoelzer 22 Oct 2008 07:41:12
time Steve Hoelzer 22 Oct 2008 07:41:12
progress bar Steve Hoelzer 25 Mar 2009 14:16:13
progressbar Merve 11 Aug 2009 11:40:51
progress bar Light Den 13 Oct 2010 21:57:46
gui tools Chris 09 Jun 2011 08:31:15
progress Vladimir Raupov 16 Jun 2011 08:23:50
waitbar James 12 Jul 2011 10:24:36

Contact us at files@mathworks.com