MATLAB Community

MATLAB, community & more

Wait bars and beyond: call me when you’re done 12

Posted by Ned Gulley,

Here’s a fun fact: the File Exchange contains nearly 70 different implementations of the wait bar (or progress bar, as it’s sometimes known). Stop and consider that number for a moment. It’s staggeringly large, especially when you consider that MATLAB already has a wait bar function.

Why do you suppose so many people have taken the time and trouble to submit yet another wait bar? What message is the File Exchange trying to send us?

I can offer a few guesses. Making a wait bar is a fun little project. It’s not too hard. And there are plenty of interesting variations on the basic theme: multiple wait bars, shiny wait bars, wait bars that tell you how much longer you’ll have to wait, ASCII wait bars for the command window. Wait bars with controls. There’s even a fake wait bar (From the description: Use it to show your boss that you can’t work at the moment because systemload is 100% and the calculations will take some time!). But the most important thing is that fact that wait bars are useful. They are useful because people love to make MATLAB sweat. Long computations mean a lot of time staring at the screen wondering when the iterations are going to stop. That gives you a lot of time to think about that cool new version of waitbar.m that you’re going to submit to the File Exchange.

I’ve done my share of waiting for MATLAB, and I’m here to tell you that I have the perfect enhancement for all those wait bars. I think the best wait bar is not one that makes you stare at a slowly growing progress bar. The best wait bar is one that lets you sip a cup of coffee and work on a crossword puzzle, and then texts you when it’s done.

How might we build such a thing?

Fortunately, as the world gets more mobile, it’s getting easier to find cheap, simple services to help you stay connected. I’ll describe one here, but there are others like it. I recently learned about a web service called Pushover. Pushover is platform for sending notifications to mobile devices. It’s essentially the same as text messaging. What makes it different from texting, though, is how easy it is to send a notification. All you need to do is send an HTTP POST request to their server.

How do you send a POST request from MATLAB? MATLAB Central to the rescue! Here’s a thread from the Newsreader in which Matthew Simoneau addresses this very question. It turns out all you need is MATLAB’s built-in URLREAD function.

Putting it all together, here’s what you need to do to add mobile notifications to your wait bar with Pushover: Get the app, get an account with them, register an app (MATLAB), register your device, and then make this call from MATLAB.

% Pushover Demo

userKey    = 'xxxxxxThisIsYourUserKeyxxxxxxx';
appToken   = 'xxxxxxThisIsYourAppTokenxxxxxx';
deviceName = 'iPhone';
msgTitle   = 'Calculation complete...';
msgText    = 'Now stop drinking coffee and get back to work!';

params = { ...
  'token',   appToken, ...
  'user',    userKey, ...
  'device',  deviceName, ...
  'title',   msgTitle, ...
  'message', msgText};

s = urlread(url,'POST',params);

Easy-peasy, eh?

Now leave a comment for us. Would you use wireless notification in conjunction with MATLAB? Also: I want to hear why you think there are so darned many wait bars.


Comments are closed.

12 CommentsOldest to Newest

Matthew Simoneau replied on : 1 of 12

An even easier way to send a text from within MATLAB is to use SENDMAIL. Most (all?) carriers provide you with an e-mail address which will forward to your phone as a text message. For example, if you have AT&T and your phone number is 617-555-1212, you can simply type:

sendmail(‘’,’Your job is done!’,’Some results’)

hash replied on : 2 of 12

Neat! Wish I had a smart-phone back in grad school. I resorted to writing a ‘ding.m’ which would play a ‘ding’ (ping/yelp/bark) so I could switch back to MATLAB’s virtual screen.

A bit strange to see a function like URL*READ* used to POST something (it makes sense if you understand HTML/HTTP requests).

Daniel Armyr replied on : 3 of 12

I was not 6 months into my first job before I wrote a function that would send me an email when whatever task I was doing was done…. This was before smartphones, but at least I could sit at my desk and not in my pitch-black lab…

Ned Gulley replied on : 5 of 12

Hi Benjamin:

No problem with the promotion – it’s right on topic, not to mention being a Pick of the Week. Thanks for the link.

Oliver Woodford replied on : 6 of 12

Matthew: sadly I don’t think the email to text service is common outside North America. It’s certainly not common in the UK.

Marie-Helene Lavoie replied on : 7 of 12

I create my own wait bar because :
1. I can change the color of the bar
2. I can add it within another GUI.
3. I can hide the bar and only show the text
3. I can change the font color and size
4. I can add an image in the top left area (company logo, warning, error, etc…)
all things that cannot be done with the matlab waitbar.m

Ned Gulley replied on : 8 of 12

Excellent! Thanks for the reply. I don’t see it on the File Exchange. Perhaps you can add it to the group? We should have an award for Most Creative Wait Bar. It’s like a cottage industry.

Jan Simon replied on : 9 of 12

Hi Ned,
I like your article very much. In fact, the flood of waitbars is a very interesting phenomenon and your analysis let me smile.

I’ve created my own waitbar with a reduced overhead required for updating and to have two bars to display the progress of the main and a sub-function. Another waitbar appears in the status line in the command window for a minimal coverage of other figures. Both are not published in the FEX, because they would not offer anything new. But I think of adding a modern Windows waitbar, which appears in the taskbar button. But I hesitate to believe, that there is really a need for a further progress indicator.

Arthur Ward replied on : 10 of 12

Another reason there are so many waitbar replacements – they all do something slightly different. (and none do all of what I want!)

1. waitbar is embarrassingly slow.
2. waitbar does not notice that the task is progressing quickly, so the waitbar may flash onscreen for only an instant.
3. waitbar does not clean up after itself, such as when an unhandled exception occurs.
4. waitbar assumes I want handle graphics.
5. waitbar makes me deal with calculating the overall progress from subtasks that are non-uniform in duration.

Needless to say, the application I work on has its own progress bar implementation.

Ned Gulley replied on : 11 of 12

Jan and Arthur:

Thanks for the comments. It’s pretty clear that our waitbar.m has some shortcomings. But there is something special about wait bars too — maybe they deserve a whole category on the File Exchange. I encourage you both to submit your versions too.

Jed Frey replied on : 12 of 12

I’ve actually written a function that uses pushover

I’ll be publishing it to the file exchange in the coming weeks after it’s been tested a bit more.