MATLAB Community

MATLAB, community & more

A Frightful Error

It’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’t banish the ghost of yesterday’s horrific memory usage. Halloween can’t be far away. How can we honor the season with appropriately creepy code?

With some help from Alex Caulway and Connell D’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?

Then I cranked out a few drawings and wrote some simple code.

Here’s the code. Save it and run it and you’ll get one of short list of images and messages designed to frighten even the most jaded of modern MATLAB users.

function msg = boo
    %BOO  A Halloween message for your friends
    %    Insert this command into your favorite code: error('%s',boo)
    
    b = imread('https://blogs.mathworks.com/community/files/boo.png');
    p = [ ...
        1,461,1,708;1,380,709,1274;1,449,1275,1939;1,387,1940,2484;
        1,396,2485,2989;1,411,2990,3577;1,374,3578,4105;1,458,4106,4733];
    m = { ...
        [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];
        [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];
        [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];
        [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];
        [84,104,101,32,100,101,109,111,32,119,105,108,108,32,98,114,101,97,107];
        [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];
        [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];
        [89,111,117,114,32,97,100,118,105,115,111,114,32,119,111,110,39,116,32,115,105,103,110]};
    
    i = randi(length(m),1,1);
    image(b(p(i,1):p(i,2),p(i,3):p(i,4)))
    colormap(gray)
    set(gca,'Visible','off','DataAspectRatio',[1 1 1]);
    title(char(m{i}),'Color','white','FontSize',15,'FontName','Times New Roman','Visible','on')
    set(gcf,'ToolBar','none','MenuBar','none','NumberTitle','off','Color','black')
    shg 

    if nargout>0
        msg = "Fatal error. " + char(m{i});
    end
    
end

Here’s an example of what you see when you run it.

For even more Halloween fun, open up a friend’s code and (after putting the “boo.m” code on the path) insert this line somewhere random.

error('%s',boo)

Then lurk. Lurk with the patience of an evil lurking thing.

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?

|
  • print

Comments

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