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!
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 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?
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
About
Bob, Brett & Jiro share their favorite user-contributed submissions from the File Exchange.
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
Instead of pause(0.01), I find adding a ‘drawnow’ command makes matlab ‘listen’ to ctrl-C
Kevin
How much does dbloop slow down a program?
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?
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