File Exchange Pick of the Week

Our best user submissions

Automatic Progress Bar

Jiro's pick this week is Progress Bars by Richard S. This was suggested by my co-worker Sarah Zaranek, whom some of you may know from her guest post in Loren's blog.

What is it with our obsessions with progress bars? You can see that there are quite a few File Exchange entries, and they all have their subtle differences in the way they operate or are implemented. Bob highlighted one just recently in this blog post. I have to admit that I have written a couple of progress bars myself, and I think the joy I get from writing a progress bar comes from the fact that it challenges me to think about both the usability of the tool, as well as the efficiency of the code. Progress bars give useful information, but we don't want them to add extra overhead. That's where I'm drawn to.

I did a double take when I saw this entry by Richard. He implemented everything using MATLAB Classes (introduced in R2008a), and it is very well commented (type doc Progress). His progress window is a JFrame, and you can have multiple progress bars. But what really impressed me was his "automatic code generation" capability. Essentially, you can annotate your script using a special syntax, and it would automatically add the boilerplate code to display the progress bars. For example, by placing "%%p#" at the for-loops you can tell Progress to interpret that as placing a progress bar.

repetitions = 10;
for rep=1:repetitions %%p1
   parameters_values = rand(1, 499);
   for ex_index=1:numel(parameters_values) %%p2
      perform_test(parameters_values(ex_index));
   end %%p2
end %%p1

Then you can simply call the script with

prog('SCRIPT_NAME')

And the progress bars will auto-magically show up!

Wow, very ingenious! Thanks, Richard, for a showing me something I haven't seen before.

Comments

Give it a try and let us know what you think here or leave a comment for Richard.




Published with MATLAB® 7.10

|
  • print
  • send email

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.