{"id":6774,"date":"2019-10-28T13:40:10","date_gmt":"2019-10-28T17:40:10","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=6774"},"modified":"2019-10-28T22:20:04","modified_gmt":"2019-10-29T02:20:04","slug":"a-frightful-error","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2019\/10\/28\/a-frightful-error\/","title":{"rendered":"A Frightful Error"},"content":{"rendered":"<p>It&#8217;s late October. The nights are getting longer (for us North Americans, anyway), and vampire processes are sucking the life from your machine. Even a hard power cycle won&#8217;t banish the ghost of yesterday&#8217;s horrific memory usage. Halloween can&#8217;t be far away. How can we honor the season with appropriately creepy code?<\/p>\n<p>With some help from Alex Caulway and Connell D&#8217;Souza here at the MATLAB Central Global Headquarters building, I decided to craft a suitably scary M-file. But what would it do? What would it say? I asked myself this question: what are some truly terrifying things for a MATLAB user to hear?<\/p>\n<p>Then I cranked out a few drawings and wrote some simple code.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"500\" height=\"339\" class=\"alignnone size-full wp-image-6778\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/sketches.jpg\" alt=\"\" \/><\/p>\n<p>Here&#8217;s the code. Save it and run it and you&#8217;ll get one of short list of images and messages designed to frighten even the most jaded of modern MATLAB users.<\/p>\n<pre>function msg = boo\r\n    %BOO  A Halloween message for your friends\r\n    %    Insert this command into your favorite code: error('%s',boo)\r\n    \r\n    b = imread('https:\/\/blogs.mathworks.com\/community\/files\/boo.png');\r\n    p = [ ...\r\n        1,461,1,708;1,380,709,1274;1,449,1275,1939;1,387,1940,2484;\r\n        1,396,2485,2989;1,411,2990,3577;1,374,3578,4105;1,458,4106,4733];\r\n    m = { ...\r\n        [89,111,117,114,32,99,111,100,101,32,119,105,108,108,32,98,101,32,104,97,117,110,116,101,100,32,98,121,32,122,111,109,98,105,101,32,78,97,78,115];\r\n        [84,104,97,116,32,112,114,111,98,108,101,109,32,115,101,116,32,105,115,32,100,117,101,32,105,110,32,50,48,32,109,105,110,117,116,101,115,44,32,97,110,100,32,70,32,126,61,32,109,97];\r\n        [82,101,118,105,101,119,101,114,115,32,99,111,110,115,101,110,115,117,115,58,32,112,97,112,101,114,32,108,97,99,107,115,32,109,101,114,105,116];\r\n        [89,111,117,39,108,108,32,110,101,118,101,114,32,102,105,110,100,32,116,104,101,32,98,117,103];\r\n        [84,104,101,32,100,101,109,111,32,119,105,108,108,32,98,114,101,97,107];\r\n        [84,104,101,32,99,121,99,108,111,109,97,116,105,99,32,99,111,109,112,108,101,120,105,116,121,32,102,111,114,32,116,104,105,115,32,102,105,108,101,32,101,120,99,101,101,100,115,32,53,48,48];\r\n        [89,111,117,114,32,99,111,110,106,101,99,116,117,114,101,32,119,97,115,32,112,114,111,118,101,100,32,105,110,32,49,56,56,55];\r\n        [89,111,117,114,32,97,100,118,105,115,111,114,32,119,111,110,39,116,32,115,105,103,110]};\r\n    \r\n    i = randi(length(m),1,1);\r\n    image(b(p(i,1):p(i,2),p(i,3):p(i,4)))\r\n    colormap(gray)\r\n    set(gca,'Visible','off','DataAspectRatio',[1 1 1]);\r\n    title(char(m{i}),'Color','white','FontSize',15,'FontName','Times New Roman','Visible','on')\r\n    set(gcf,'ToolBar','none','MenuBar','none','NumberTitle','off','Color','black')\r\n    shg \r\n\r\n    if nargout&gt;0\r\n        msg = \"Fatal error. \" + char(m{i});\r\n    end\r\n    \r\nend<\/pre>\n<p>Here&#8217;s an example of what you see when you run it.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" width=\"432\" height=\"348\" class=\"alignnone size-full wp-image-6786\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/paper.png\" alt=\"\" \/><\/p>\n<p>For even more Halloween fun, open up a friend&#8217;s code and (after putting the &#8220;boo.m&#8221; code on the path) insert this line somewhere random.<\/p>\n<pre>error('%s',boo)<\/pre>\n<p>Then lurk. Lurk with the patience of an evil lurking thing.<\/p>\n<p>And by the way, what messages would you add to the list here? What are more some scary messages updated for the modern engineer and scientist?<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/sketches.jpg\" onError=\"this.style.display ='none';\" \/><\/div>\n<p>It&#8217;s late October. The nights are getting longer (for us North Americans, anyway), and vampire processes are sucking the life from your machine. Even a hard power cycle won&#8217;t banish the&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2019\/10\/28\/a-frightful-error\/\">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":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6774"}],"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=6774"}],"version-history":[{"count":11,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6774\/revisions"}],"predecessor-version":[{"id":6803,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/6774\/revisions\/6803"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=6774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=6774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=6774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}