{"id":2240,"date":"2008-06-27T10:33:28","date_gmt":"2008-06-27T15:33:28","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2008\/06\/27\/atomic-clock-alarm-challenge\/"},"modified":"2016-11-01T17:34:06","modified_gmt":"2016-11-01T21:34:06","slug":"atomic-clock-alarm-challenge","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2008\/06\/27\/atomic-clock-alarm-challenge\/","title":{"rendered":"Atomic clock + alarm challenge"},"content":{"rendered":"<div class=\"alert alert-info\"> <span class=\"alert_icon icon-alert-info-reverse\"><\/span><p class=\"alert_heading\"><strong>Note<\/strong><\/p><p>The file submission referenced in this post is no longer available on File Exchange.<\/p><\/div>\r\n\r\nBob's pick this week has a twist.\r\n\r\n&nbsp;\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n\t<li><a href=\"#1\">The challenge<\/a><\/li>\r\n\t<li><a href=\"#2\">The pick<\/a><\/li>\r\n\t<li><a href=\"#3\">The catch<\/a><\/li>\r\n\t<li><a href=\"#6\">The incentive<\/a><\/li>\r\n\t<li><a href=\"#7\">Talk to us<\/a><\/li>\r\n<\/ul>\r\n<\/div>\r\n<h3>The challenge<a name=\"1\"><\/a><\/h3>\r\nLast week <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2238\">Brett's pick<\/a> was a MATLAB alarm clock. But an alarm is only as good as the clock behind it. Your mission, should you accept, is to hook\r\nup the alarm to an atomic clock!\r\n<h3>The pick<a name=\"2\"><\/a><\/h3>\r\n\"How?\" you might ask. That's where this week's pick comes in. Java Time by Scott Burnside is your other building block.\r\n<h3>The catch<a name=\"3\"><\/a><\/h3>\r\nScott's motivation was a Java example, so his MATLAB GUI does the deed using Java code and data types.\r\n\r\nI suggest excising the portion of his code that fetches the time. Build a wrapper function to return that time value as a\r\n<tt>datenum<\/tt> for example.\r\n<h3>The incentive<a name=\"6\"><\/a><\/h3>\r\nSubmit your atomic alarm clock to the file exchange and it might just become our next \"Pick of the Week.\" Good luck!\r\n<h3>Talk to us<a name=\"7\"><\/a><\/h3>\r\nIf you have questions or comments about this challenge, tell us about it <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2240#respond\">here<\/a>.\r\n\r\n<script>\/\/ <![CDATA[\r\nfunction grabCode_b496b4bf046f478fab0b6901c2a0fbb5() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='b496b4bf046f478fab0b6901c2a0fbb5 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' b496b4bf046f478fab0b6901c2a0fbb5';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Robert Bemis';\r\n        copyright = 'Copyright 2008 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('\r\n\r\n<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\r\n\r\n\r\n\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }\r\n\/\/ ]]><\/script>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight: lighter; font-style: italic; color: gray;\">\r\n<a><span style=\"font-size: x-small; font-style: italic;\">Get\r\nthe MATLAB code\r\n<noscript>(requires JavaScript)<\/noscript><\/span><\/a>\r\n\r\nPublished with MATLAB\u00ae 7.6<\/p>\r\n\r\n<\/div>\r\n<!--\r\nb496b4bf046f478fab0b6901c2a0fbb5 ##### SOURCE BEGIN #####\r\n%% Bob's challenge: MATLAB Atomic Alarm Clock\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadAuthor.do?objectId=969735&objectType=author % Bob>'s pick this week has a twist.\r\n%% The challenge\r\n% Last week <https:\/\/blogs.mathworks.com\/pick\/?p=2238 Brett's pick> was a\r\n% MATLAB alarm clock. But an alarm is only as good as the clock behind it.\r\n% Your mission, should you accept, is to hook up the alarm to an atomic clock!\r\n%% The pick\r\n% \"How?\" you might ask. That's where this week's pick comes in.\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/loadFile.do?objectId=7666 Java Time>\r\n% by Scott Burnside is your other building block.\r\n%% The catch\r\n% Scott's motivation was a Java example, so his MATLAB GUI does the deed using\r\n% Java code and data types.\r\n%%\r\n% <<https:\/\/www.mathworks.com\/matlabcentral\/files\/7666\/java_time.GIF>>\r\n%%\r\n% I suggest excising the portion of his code that fetches the time. Build a\r\n% wrapper function to return that time value as a |datenum| for example.\r\n%% The incentive\r\n% Submit your atomic alarm clock to the file exchange and it might just become\r\n% our next \"Pick of the Week.\" Good luck!\r\n%% Talk to us\r\n% If you have questions or comments about this challenge, tell us about it\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2240#respond here>.\r\n\r\n##### SOURCE END ##### b496b4bf046f478fab0b6901c2a0fbb5\r\n-->","protected":false},"excerpt":{"rendered":"<p> NoteThe file submission referenced in this post is no longer available on File Exchange.\r\n\r\nBob's pick this week has a twist.\r\n\r\n&nbsp;\r\nContents\r\n\r\n\r\n\tThe challenge\r\n\tThe pick\r\n\tThe catch\r\n\tThe... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2008\/06\/27\/atomic-clock-alarm-challenge\/\">read more >><\/a><\/p>","protected":false},"author":46,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2240"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2240"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2240\/revisions"}],"predecessor-version":[{"id":8000,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2240\/revisions\/8000"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}