{"id":520,"date":"2011-05-27T15:30:01","date_gmt":"2011-05-27T15:30:01","guid":{"rendered":"https:\/\/blogs.mathworks.com\/videos\/2011\/05\/27\/top-five-productivity-practices-in-matlab\/"},"modified":"2011-05-27T15:30:01","modified_gmt":"2011-05-27T15:30:01","slug":"top-five-productivity-practices-in-matlab","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/videos\/2011\/05\/27\/top-five-productivity-practices-in-matlab\/","title":{"rendered":"Top five productivity practices in MATLAB"},"content":{"rendered":"I teach the &#8220;MATLAB 101&#8221; course for all of our new technical support engineers at MathWorks.  When I come to their computers, I become aware of little tweaks I have made to my working style and MATLAB environment that save me steps, or a few seconds HUNDREDS of times a day.  Here are five tips that you can implement right now to make things better for you.\r\n<ol>\r\n\t<li><strong>Use shortcuts on desktop<\/strong><\/li>\r\nYou can add custom shortcuts to the MATLAB desktop to get single-click access to any MATLAB code you run often.  I see so many people that leave their MATLAB desktop with just the default shortcuts:\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/videos\/2011\/05\/noshortcuts.jpg\" alt=\"noshortcuts.jpg\" \/>\r\n<p>\r\nI made the following shortcuts by just dragging code from the command window or editor directly to the shortcut bar. You can learn more about making shortcuts <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2011a\/techdoc\/\/matlab_env\/bq37azl-1.html\">here<\/a>. Here are the shortcuts I find myself using all of the time:\r\n<p>\r\n<strong>Gets MATLAB back into a fresh state<\/strong>\r\n<pre><code>clear\r\nclc\r\nclose all\r\n<\/code><\/pre>\r\n<strong>Opens the current directory in Windows<\/strong>\r\n<pre><code>winopen(pwd)\r\n\r\n<\/code><\/pre>\r\n<strong>Changes directory to a common destination<\/strong>\r\n<pre><code>cd('C:\\Users\\dhull\\Desktop')\r\n<\/code><\/pre>\r\n<strong>Make all future figure windows start docked<\/strong>\r\n<pre><code>set(0,'DefaultFigureWindowStyle','docked');<\/code><\/pre>\r\n<strong>Make all future figure windows start normally<\/strong>\r\n<pre><code>set(0,'DefaultFigureWindowStyle','undocked');<\/code><\/pre>\r\n\t<li><strong>Dock windows in the desktop<\/strong><\/li>\r\nI see so many people  spend a few seconds hunting for the editor, figure windows, etc *every*  time they switch contexts.  This is so easily avoided, just put MATLAB  full screen, dock the desktop components if they aren&#8217;t already docked (using the little arrow in the upper right corner of each component)\u00a0 and rearrange the desktop components until you can see  everything at once.\r\n\t<li><strong>Make throw-away scripts<\/strong><\/li>\r\nMATLAB is great because you can use it interactively.  However, I see people too often do everything at the command line and forget how they got to whatever state they end up in.  They then need to dig around the command history looking for the specific commands they used that worked.\r\n\r\nIf you work in a script, and just keep modifying it as you go, you know exactly how you got to the state you finish in.  I also recommend starting the script with\r\n<pre><code>clear\r\nclc\r\nclose all\r\n<\/code><\/pre>\r\nso that you always start in a known state.\u00a0 One small gotcha &#8211; if you are using the debugger, don&#8217;t include the clear command at the beginning of your script.\u00a0 It will clear your debugger breakpoints in addition to clearing your workspace variables.\r\n\t<li><strong>Use F5 to save and run<\/strong><\/li>\r\nThe script I mentioned above is a lot easier to iterate on if you just hit F5 to save and run.\r\n\t<li><strong>Use run configurations<\/strong><\/li>\r\nYou can click the down arrow on the right side of this button\r\n<p>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/videos\/2011\/05\/runconfig.jpg\" alt=\"runconfig.jpg\" \/>\r\n<p>\r\nto see a script that you can run when you hit F5.  This is an advanced form of the above tip.  It allows you to specify a script to run when you hit F5.  This is often used to set up the environment for a function that you are working on.\r\n<p>\r\nThese five tips will save you a few seconds each, hundreds of times a day.  They will make MATLAB programming much faster and keep you in the flow!<\/ol>","protected":false},"excerpt":{"rendered":"<p>I teach the &#8220;MATLAB 101&#8221; course for all of our new technical support engineers at MathWorks.  When I come to their computers, I become aware of little tweaks I have made to my working&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/videos\/2011\/05\/27\/top-five-productivity-practices-in-matlab\/\">read more >><\/a><\/p>","protected":false},"author":68,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[17],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/520"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/users\/68"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/comments?post=520"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/posts\/520\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/media?parent=520"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/categories?post=520"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/videos\/wp-json\/wp\/v2\/tags?post=520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}