| Using Simulink | ![]() |
Setting Breakpoints
The Simulink debugger allows you to define stopping points in a simulation called breakpoints. You can then run a simulation from breakpoint to breakpoint, using the debugger's continue command. The debugger lets you define two types of breakpoints: unconditional and conditional. An unconditional breakpoint occurs whenever a simulation reaches a method that you specified previously. A conditional breakpoint occurs when a condition that you specified in advance arises in the simulation.
Breakpoints are useful when you know that a problem occurs at a certain point in your program or when a certain condition occurs. By defining an appropriate breakpoint and running the simulation via the continue command, you can skip immediately to the point in the simulation where the problem occurs.
Setting Unconditional Breakpoints
You can set unconditional breakpoints from the
Setting Breakpoints from the Debugger Toolbar
To set a breakpoint on a block's methods, select the block and then click the Breakpoint button on the debugger toolbar.
The debugger displays the name of the selected block in the Break/Display points panel of its Breakpoints pane.
| Note Clicking the Breakpoint button on the toolbar sets breakpoints on the invocations of a block's methods in major time steps. To enable breakpoints in minor time steps, you must select the debugger's Minor time steps option (see Breaking in Minor Time Steps). |
You can temporarily disable the breakpoints on a block by deselecting the check box in the breakpoints column of the panel. To clear the breakpoints on a block and remove its entry from the panel, select the entry and then click the Remove selected point button on the panel.
Note
You cannot set a breakpoint on a virtual block. A virtual block is a block whose function is purely graphical: it indicates a grouping or relationship among a model's computational blocks. The debugger warns you if you attempt to set a breakpoint on a virtual block. You can obtain a listing of a model's nonvirtual blocks, using the slist command (see Displaying a Model's Nonvirtual Blocks). |
Setting Breakpoints from the Simulation Loop Pane
To set a breakpoint at a particular invocation of a method displayed in the Simulation Loop pane, select the check box next to the method's name in the breakpoint column of the pane.
To clear the breakpoint, deselect the check box.
Setting Breakpoints from the MATLAB Command Window
In command-line mode, use the break and bafter commands to set breakpoints before or after a specified method, respectively. Use the clear command to clear breakpoints.
| Debug Pointer | Setting Conditional Breakpoints | ![]() |
© 1994-2005 The MathWorks, Inc.