{"id":1338,"date":"2012-08-13T13:12:30","date_gmt":"2012-08-13T18:12:30","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=1338"},"modified":"2018-01-08T16:24:28","modified_gmt":"2018-01-08T21:24:28","slug":"wait-bars-and-beyond-call-me-when-youre-done","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2012\/08\/13\/wait-bars-and-beyond-call-me-when-youre-done\/","title":{"rendered":"Wait bars and beyond: call me when you&#8217;re done"},"content":{"rendered":"<style type=\"text\/css\">\npre.codeinput { margin:0px 0px 20px; padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }\n<\/style>\n<p>Here&#8217;s a fun fact: the File Exchange contains nearly <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/index?utf8=%E2%9C%93&amp;term=tag%3A%22waitbar%22\">70 different implementations of the wait bar<\/a> (or progress bar, as it&#8217;s sometimes known). Stop and consider that number for a moment. It&#8217;s staggeringly large, especially when you consider that <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/waitbar.html\">MATLAB already has a wait bar function<\/a>.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1353\" title=\"waitbar\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/waitbar1.png\" alt=\"\" width=\"509\" height=\"115\" \/><\/p>\n<p>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?<\/p>\n<p>I can offer a few guesses. Making a wait bar is a fun little project. It&#8217;s not too hard. And there are plenty of interesting variations on the basic theme: <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/37309-multiwaitbar\">multiple wait bars<\/a>, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/26589-multiwaitbar--label--varargin--\">shiny wait bars<\/a>, wait bars that <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/22161-waitbar-with-time-estimation\">tell you how much longer you&#8217;ll have to wait<\/a>, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/11796-another-ascii-progress-bar\">ASCII wait bars<\/a> for the command window. Wait bars with <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/15231-awaitbar--alternative-to-waitbar\">controls<\/a>. There&#8217;s even a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/10730-fakebar\">fake wait bar<\/a> (From the description: <em>Use it to show your boss that you can&#8217;t work at the moment because systemload is 100% and the calculations will take some time!<\/em>). 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&#8217;re going to submit to the File Exchange.<\/p>\n<p>I&#8217;ve done my share of waiting for MATLAB, and I&#8217;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&#8217;s done.<\/p>\n<p>How might we build such a thing?<\/p>\n<p>Fortunately, as the world gets more mobile, it&#8217;s getting easier to find cheap, simple services to help you stay connected. I&#8217;ll describe one here, but there are others like it. I recently learned about a web service called <a href=\"https:\/\/pushover.net\/faq\">Pushover<\/a>. Pushover is platform for sending notifications to mobile devices. It&#8217;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 <a href=\"http:\/\/en.wikipedia.org\/wiki\/POST_(HTTP)\">HTTP POST request<\/a> to their server.<\/p>\n<p>How do you send a POST request from MATLAB? MATLAB Central to the rescue! Here&#8217;s a <a>thread from the Newsreader<\/a> in which Matthew Simoneau addresses this very question. It turns out all you need is MATLAB&#8217;s built-in <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/urlread.html\">URLREAD<\/a> function.<\/p>\n<p>Putting it all together, here&#8217;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.<\/p>\n<pre class=\"codeinput\">\r\n% Pushover Demo<\/code>\r\n\r\nuserKey    = 'xxxxxxThisIsYourUserKeyxxxxxxx';\r\nappToken   = 'xxxxxxThisIsYourAppTokenxxxxxx';\r\ndeviceName = 'iPhone';\r\nmsgTitle   = 'Calculation complete...';\r\nmsgText    = 'Now stop drinking coffee and get back to work!';\r\n\r\nparams = { ...\r\n  'token',   appToken, ...\r\n  'user',    userKey, ...\r\n  'device',  deviceName, ...\r\n  'title',   msgTitle, ...\r\n  'message', msgText};\r\n\r\ns = urlread(url,'POST',params);\r\n<\/pre>\n<p>Easy-peasy, eh?<\/p>\n<p>Now leave a comment for us. Would you use wireless notification in conjunction with MATLAB? Also: I want to hear why <em>you<\/em> think there are so darned many wait bars.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\npre.codeinput { margin:0px 0px 20px; padding:10px; border:1px solid #d3d3d3; background:#f7f7f7; }<\/p>\n<p>Here&#8217;s a fun fact: the File Exchange contains nearly 70 different implementations of the&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2012\/08\/13\/wait-bars-and-beyond-call-me-when-youre-done\/\">read more >><\/a><\/p>\n","protected":false},"author":69,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[50,228,227,226],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1338"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=1338"}],"version-history":[{"count":33,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1338\/revisions"}],"predecessor-version":[{"id":5078,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1338\/revisions\/5078"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=1338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=1338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=1338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}