Stuart’s MATLAB Videos

Watch and Learn

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

Sean de Wolski replied on : 1 of 4

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

James K replied on : 2 of 4

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

Your email address will not be published. Required fields are marked *

What is 2 + 5 ?

Preview: hide