File Exchange Pick of the Week

August 28th, 2009

A great utility for debugging

Brett's Pick this week is dbmute and unmute, companion functions that facilitate code tweaking and debugging.

Those of you who read my colleagues' blog Ken & Mike on the MATLAB Desktop may have already been introduced to today's pick; it comes to us from fellow MathWorker and blogger Ken Orr (his first official submission--welcome to the File Exchange, Ken!).

Back in mid-July, Ken wrote a blog post on Muting Breakpoints. He described how he uses breakpoints to help him debug his code, and he wrote that he wanted the ability to quickly disable (and re-enable) those breaks. To solve the problem, Ken wrote, and showed the code for, dbmute and dbunmute. I adopted the functions immediately--they've quickly become an integral part of my own code development workflow. I also commented on that post, suggesting that these functions belong on the MATLAB Central File Exchange, and hinting about their destiny as "Picks of the Week." Good to my word, today's Pick honors Ken's submission.

One side note: Ken suggested in a final thought that it might be useful to create shortcuts to the functions:

I took it one step farther, and implemented a single shortcut that toggles my breakpoints:

Anyone care to venture a guess how I did that?


Get the MATLAB code

Published with MATLAB® 7.8

2 Responses to “A great utility for debugging”

  1. Corbin Holland replied on :

    Here’s how I would write the toggle shortcut:

    s = dbstatus('-completenames');
    mute = true;
    for i = 1:length(s)
       if (strcmp(s(i).expression,'false'))
          mute = false;
          break;
       end
    end
    if (mute)
       dbmute
       disp('Muting all breakpoints');
    else
       dbunmute
       disp('Unmuting all breakpoints');
    end
    
  2. Brett replied on :

    Hi Corbin,
    Nice! My version simply stored the mute status in, and queried from, the appdata of the MATLAB root:

    muteStatus = getappdata(0,'dbmuteStatus');
    if isempty(muteStatus) || ~muteStatus
        setappdata(0,'dbmuteStatus',true);
        dbmute
    else
        setappdata(0,'dbmuteStatus',false);
        dbunmute
    end
    

    But your version works well, too. If you’ll respond directly to my email…HINT:

    char(cumsum([98 16 -13 15 0 -70 69 -11 7 -10 7 7 -4 -1 -46 45 -12 19 -12 15 -8 3 -7 8 -69 53 12 -2]))
    

    with your snail mail address, I’d like to send you a small token of our appreciation!

Leave a Reply

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>

If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).


Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.

  • Zach: Hi Doug and Les, I didn’t have a lot of time to mess with this, but I did find a work-around. I plotted...
  • hamed: k
  • Les: @Zach This isn’t exactly what you are looking for but at least it puts all three parameters on the same...
  • Zach: Thanks for your suggestions Doug. I’ll give that a shot and see what happens. I’ve seen many of...
  • Doug: @Zach, I would say to use plotYYY, because that is close to what you want, but using depth as Y makes sense....
  • Doug: @Teja, I think this will work: http://www.mathworks .com/access/helpdesk /help/techdoc/ref...
  • Gify: merry christmas :) nice christmas tree! Regards, Janet Gify
  • Teja: Dear Doug Is there anyway to plot a surface from nonuniform data without meshgrid and griddata? Basically i...
  • Zach: I’m working with geophysical data, so I’d like to produce a depth profile. The y-axis would be...
  • Doug: @Ashok First, please do not use variable names that are MATLAB commands (std and mean). Second, p(j) should be...

These postings are the author's and don't necessarily represent the opinions of The MathWorks.