File Exchange Pick of the Week

March 15th, 2006

Stop it!

Sometimes you just know you are going to want to break out of a loop in MATLAB, but ctrl-C is not what you are looking for because you are going to want to debug. A conditional breakpoint is not going to work either (right click on a breakpoint in the editor to make it conditional). Greg Aloe’s post: dbloop will do the job quite nicely. It will have MATLAB listen for a certain keypress and then enter debug mode in the middle of the loop. Brilliant!

5 Responses to “Stop it!”

  1. Antenna Geek replied on :

    Regarding Ctrl-C loop breaking:

    It frequently happens on my machine that MATLAB won’t break out of a loop on Ctrl-C. It is running at 100% CPU and is not “listening” to Ctrl-C until the program is completed.

    I usually insert

    pause(0.01);

    into the loop and that solves the problem.

    Regards,

    Eric

  2. Kevin Murphy replied on :

    Instead of pause(0.01), I find adding a ‘drawnow’ command makes matlab ‘listen’ to ctrl-C

    Kevin

  3. Bob replied on :

    How much does dbloop slow down a program?

  4. Malambo replied on :

    I have designed a GUI for image classification. I have used a for loop for selecting samples using roipoly. The problem i have is that i can not zoom while selecting my samples. Is there a way I could pause the for loop to zoom to an area of interest and resume afterwards?

  5. Doug replied on :

    Malambo,

    I suspect that you are going to need to change your architecture slightly to accomplish this. Once you are running ROIPOLY, you will not be able to zoom. I would make a button that says “Capture” that then gets you in capture mode. You can zoom as normal between captures.

    Doug

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.