{"id":174,"date":"2009-03-03T19:29:23","date_gmt":"2009-03-03T19:29:23","guid":{"rendered":"https:\/\/blogs.mathworks.com\/loren\/2009\/03\/03\/whats-in-your-startupm\/"},"modified":"2009-03-03T19:31:04","modified_gmt":"2009-03-03T19:31:04","slug":"whats-in-your-startupm","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/loren\/2009\/03\/03\/whats-in-your-startupm\/","title":{"rendered":"What&#8217;s in Your startup.m?"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p>Several of us at The MathWorks were recently discussing how we each use <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/ref\/startup.html\"><tt>startup.m<\/tt><\/a>.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">What is startup.m?<\/a><\/li>\r\n         <li><a href=\"#2\">finish.m Anyone?<\/a><\/li>\r\n         <li><a href=\"#3\">What Do You Use startup.m For?<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>What is startup.m?<a name=\"1\"><\/a><\/h3>\r\n   <p>I typically don't use <tt>startup.m<\/tt>, but when I do, I have one sitting in a particular directory where there's other code I want to use as well.  And I make\r\n      a MATLAB shortcut in that directory (this is using Windows) that specifies this particular directory as the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/matlab_env\/f8-10506.html\">starting location<\/a> for MATLAB. When you use this icon for starting MATLAB, it starts in the specified directory, and finds and runs the <tt>startup.m<\/tt> located there.  I usually do this for presentations that I give, so my <tt>startup.m<\/tt> generally includes commands that change default font sizes for figures so the annotations are visible in a large, dimly lit\r\n      room.  I have also helped users customize their own <tt>startup.m<\/tt>.  Commonly, the contents again includes commands to set up preferences for graphics, for example, to have <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/ref\/grid.html\"><tt>grid<\/tt><\/a> on by default (use something like this: <tt>set(0,'defaultAxesXGrid','on')<\/tt>, and similarly for 'YGrid' and 'ZGrid'). I've also seen users randomize the starting point for creating <a href=\"https:\/\/blogs.mathworks.com\/loren\/category\/random\/\">random numbers<\/a>.\r\n   <\/p>\r\n   <h3>finish.m Anyone?<a name=\"2\"><\/a><\/h3>\r\n   <p>The analog to <tt>startup.m<\/tt> is <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/ref\/finish.html\"><tt>finish.m<\/tt><\/a>. This can be used to save data, ask for confirmation to quit, release a hardware resource, finish writing out a file, etc.\r\n   <\/p>\r\n   <h3>What Do You Use startup.m For?<a name=\"3\"><\/a><\/h3>\r\n   <p>Do you use <tt>startup.m<\/tt> or <tt>finish.m<\/tt>?  If so, I'd love to hear what you put in these.  Post your thoughts <a href=\"https:\/\/blogs.mathworks.com\/loren\/?p=174#respond\">here<\/a>.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_34f15aa317be4d84bc905566760326fa() {\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='34f15aa317be4d84bc905566760326fa ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 34f15aa317be4d84bc905566760326fa';\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 = 'Loren Shure';\r\n        copyright = 'Copyright 2009 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<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>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_34f15aa317be4d84bc905566760326fa()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; 7.7<br><\/p>\r\n<\/div>\r\n<!--\r\n34f15aa317be4d84bc905566760326fa ##### SOURCE BEGIN #####\r\n%% What's in Your startup.m?\r\n% Several of us at The MathWorks were recently discussing how we each use\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/ref\/startup.html |startup.m|>.\r\n%% What is startup.m?\r\n% I typically don't use |startup.m|, but when I do, I have one sitting in a\r\n% particular directory where there's other code I want to use as well.  And\r\n% I make a MATLAB shortcut in that directory (this is using Windows) that\r\n% specifies this particular directory as the \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/matlab_env\/f8-10506.html starting location> for MATLAB.\r\n% When you use this icon for starting MATLAB, it starts in the specified\r\n% directory, and finds and runs the |startup.m| located there.  I usually\r\n% do this for presentations that I give, so my |startup.m| generally\r\n% includes commands that change default font sizes for figures so the\r\n% annotations are visible in a large, dimly lit room.  I have also helped\r\n% users customize their own |startup.m|.  Commonly, the contents again\r\n% includes commands to set up preferences for graphics, for example, to\r\n% have <https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/ref\/grid.html |grid|> \r\n% on by default (use something like this:\r\n% |set(0,'defaultAxesXGrid','on')|, and similarly for 'YGrid' and 'ZGrid').\r\n% I've also seen users randomize the starting point for creating \r\n% <https:\/\/blogs.mathworks.com\/loren\/category\/random\/ random numbers>.\r\n%% finish.m Anyone?\r\n% The analog to |startup.m| is \r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2008b\/techdoc\/ref\/finish.html |finish.m|>.\r\n% This can be used to save data, ask for confirmation to quit, release a\r\n% hardware resource, finish writing out a file, etc.\r\n%% What Do You Use startup.m For? \r\n% Do you use |startup.m| or |finish.m|?  If so, I'd love to hear what you\r\n% put in these.  Post your thoughts\r\n% <https:\/\/blogs.mathworks.com\/loren\/?p=174#respond here>.\r\n##### SOURCE END ##### 34f15aa317be4d84bc905566760326fa\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Several of us at The MathWorks were recently discussing how we each use startup.m.\r\n      \r\n   \r\n   Contents\r\n   \r\n      \r\n     ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/loren\/2009\/03\/03\/whats-in-your-startupm\/\">read more >><\/a><\/p>","protected":false},"author":39,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[15],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/174"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/users\/39"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/loren\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}