{"id":2458,"date":"2009-08-28T13:24:38","date_gmt":"2009-08-28T13:24:38","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/2009\/08\/28\/a-great-utility-for-debugging\/"},"modified":"2009-08-31T18:42:57","modified_gmt":"2009-08-31T18:42:57","slug":"a-great-utility-for-debugging","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2009\/08\/28\/a-great-utility-for-debugging\/","title":{"rendered":"A great utility for debugging"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911\">Brett<\/a>'s Pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/24695-dbmute-and-dbunmute\">dbmute and unmute<\/a>, companion functions that facilitate code tweaking and debugging.\r\n      <\/p>\r\n   <\/introduction>\r\n   <p>Those of you who read my colleagues' blog <a href=\"https:\/\/blogs.mathworks.com\/community\/\">Ken &amp; Mike on the MATLAB Desktop<\/a> may have already been introduced to today's pick; it comes to us from fellow MathWorker and blogger <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/46647\">Ken Orr<\/a> (his first official submission--welcome to the File Exchange, Ken!).\r\n   <\/p>\r\n   <p>Back in mid-July, Ken wrote a blog post on <a href=\"https:\/\/blogs.mathworks.com\/community\/2009\/07\/13\/muting-breakpoints\/\">Muting Breakpoints<\/a>. He described how he uses breakpoints to help him debug his code, and he wrote that he wanted the ability to quickly disable\r\n      (and re-enable) those breaks. To solve the problem, Ken wrote, and showed the code for, <tt>dbmute<\/tt> and <tt>dbunmute<\/tt>. I adopted the functions immediately--they've quickly become an integral part of my own code development workflow. I also\r\n      <a href=\"https:\/\/blogs.mathworks.com\/community\/2009\/07\/13\/muting-breakpoints\/#comment-6346\">commented<\/a> on that post, suggesting that these functions belong on the MATLAB Central File Exchange, and hinting about their destiny\r\n      as \"Picks of the Week.\" Good to my word, today's Pick honors Ken's submission.\r\n   <\/p>\r\n   <p>One side note: Ken suggested in a final thought that it might be useful to <a href=\"https:\/\/blogs.mathworks.com\/community\/2007\/03\/29\/shortcuts-for-commonly-used-code\/\">create shortcuts<\/a> to the functions:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/shortcuts.png\"> <\/p>\r\n   <p>I took it one step farther, and implemented a <i>single<\/i> shortcut that toggles my breakpoints:\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/shortcuts2.png\"> <\/p>\r\n   <p>Anyone care to <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=2458#respond\">venture a guess<\/a> how I did that?\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_59ee3a0dd89041878b308bd24ac95798() {\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='59ee3a0dd89041878b308bd24ac95798 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 59ee3a0dd89041878b308bd24ac95798';\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 = 'Brett Shoelson';\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_59ee3a0dd89041878b308bd24ac95798()\"><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.8<br><\/p>\r\n<\/div>\r\n<!--\r\n59ee3a0dd89041878b308bd24ac95798 ##### SOURCE BEGIN #####\r\n%% A great utility for debugging\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/911 Brett>'s\r\n% Pick this week is <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/24695-dbmute-and-dbunmute dbmute and unmute>,\r\n% companion functions that facilitate code\r\n% tweaking and debugging.\r\n\r\n%%\r\n% Those of you who read my colleagues'\r\n% blog <https:\/\/blogs.mathworks.com\/community\/ Ken & Mike on the MATLAB Desktop> may have already been introduced to today's\r\n% pick; it comes to us from fellow MathWorker and blogger\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/46647 Ken Orr>\r\n% (his first official submissionREPLACE_WITH_DASH_DASHwelcome to the\r\n% File Exchange, Ken!).\r\n\r\n%%\r\n% Back in mid-July, Ken wrote a blog post on\r\n% <https:\/\/blogs.mathworks.com\/community\/2009\/07\/13\/muting-breakpoints\/ Muting Breakpoints>.\r\n% He described how he uses breakpoints to help him debug his code,\r\n% and he wrote that he wanted the ability to quickly disable (and\r\n% re-enable) those breaks. To solve the problem, Ken\r\n% wrote, and showed the code for, |dbmute| and |dbunmute|. I adopted the functions immediatelyREPLACE_WITH_DASH_DASHthey've quickly become an integral part of my own code development workflow.\r\n% I also\r\n% <https:\/\/blogs.mathworks.com\/community\/2009\/07\/13\/muting-breakpoints\/#comment-6346 commented> on that post, suggesting that these\r\n% functions belong on the MATLAB Central File Exchange, and\r\n% hinting about their destiny as \"Picks of the Week.\" Good to my\r\n% word, today's Pick honors Ken's submission.\r\n\r\n%% \r\n% One side note: Ken suggested in a final thought that it might\r\n% be useful to <https:\/\/blogs.mathworks.com\/community\/2007\/03\/29\/shortcuts-for-commonly-used-code\/ create shortcuts> to the functions:\r\n\r\n%%\r\n% \r\n% <<shortcuts.png>>\r\n% \r\n\r\n%%\r\n% I took it one step farther, and implemented a _single_ shortcut\r\n% that toggles my breakpoints:\r\n\r\n%%\r\n% \r\n% <<shortcuts2.png>>\r\n% \r\n\r\n%%\r\n% Anyone care to\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=2458#respond venture a guess> how I did that? \r\n##### SOURCE END ##### 59ee3a0dd89041878b308bd24ac95798\r\n-->","protected":false},"excerpt":{"rendered":"<p>\r\n   \r\n      Brett's Pick this week is dbmute and unmute, companion functions that facilitate code tweaking and debugging.\r\n      \r\n   \r\n   Those of you who read my colleagues' blog Ken &amp; Mike on... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2009\/08\/28\/a-great-utility-for-debugging\/\">read more >><\/a><\/p>","protected":false},"author":34,"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\/2458"}],"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\/34"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=2458"}],"version-history":[{"count":0,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/2458\/revisions"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=2458"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=2458"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=2458"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}