Doug's MATLAB Video Tutorials

Quick Tip: Speeding up debugging iterations 4

Posted by Doug Hull,

This week’s video is a quick tip to help speed up iterations when debugging MATLAB code. If your code requires user interactivity, such as selecting a file or folder from a dialog box, consider hardcoding a representative input value into your file while debugging. This eliminates for you to perform the interactive steps every time you run the code.

The video shows a couple of different approaches for switching between your debugging code and the code for the final version.

4 CommentsOldest to Newest

If you are using breakpoints in the file, you can use DBSTATUS to identify whether you’re debugging or not:

function broken

if isempty(dbstatus(mfilename))
file = uigetfile();
file = ‘foo.txt’;

a = b


Try it both with and without a breakpoint on line a = b

Hey Doug,
Good call on the direct input when debugging. As a GUI developer I used to debug things this way and it slows you down so much.

I like the flagdebug idea, but what about using something like ? That way you won’t accidentally leave a flag on or off.


Add A Comment

What is 8 + 9?

Preview: hide

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