MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Set Breakpoints


In this section...
“Standard Breakpoints” on page 22-9
“Conditional Breakpoints” on page 22-10
“Error Breakpoints” on page 22-11
“Breakpoints in Anonymous Functions” on page 22-11
“Invalid Breakpoints” on page 22-12
“Disable Breakpoints” on page 22-13
“Clear Breakpoints” on page 22-13

Setting breakpoints pauses the execution of your MATLAB program so that you can
examine values where you think a problem might be. You can set breakpoints using the
Editor or by using functions in the Command Window.

There are three types of breakpoints:


  • Standard breakpoints

  • Conditional breakpoints

  • Error breakpoints


You can set breakpoints only at executable lines in saved files that are in the current
folder or in folders on the search path. You can set breakpoints at any time, whether
MATLAB is idle or busy running a file.

By default, MATLAB automatically opens files when it reaches a breakpoint. To disable
this option:

1
From the Home tab, in the Environment section, click Preferences.

The Preferences dialog box opens.

(^2) Select MATLAB > Editor/Debugger.
(^3) Clear the Automatically open file when MATLAB reaches a breakpoint option
and click OK.
22 Debugging MATLAB Code

Free download pdf