Set Conditional Breakpoints for Stepping a Simulation

A conditional breakpoint is triggered based on a specified expression evaluated on a signal. When the breakpoint is triggered, the simulation pauses.

Set conditional breakpoints to stop Simulation Stepper when a specified condition is met. One example of a use for conditional breakpoints is when you want to examine results after a certain number of iterations in a loop.

Simulation Stepper allows you to set conditional breakpoints for scalar signals. These breakpoints appear for signals:

BreakpointDescription
Enabled breakpoint. Appears when you add the conditional breakpoint.
Enabled breakpoint hit. Appears when the simulation reaches the condition specified and triggers the breakpoint.
Disabled breakpoint. Appears when you disable a conditional breakpoint.
Invalid breakpoint. Appears when the software determines that a breakpoint is invalid for the signal. An enabled breakpoint image changes to this one when, during simulation, the software determines that the conditional breakpoint is invalid.

When setting conditional breakpoints, keep in mind that:

  • When simulation arrives at a conditional breakpoint, simulation does not stop when the block is executed. Instead, simulation stops after the current simulation step completes.

  • You can add multiple conditional breakpoints to a signal line.

Add and Edit Conditional Breakpoints

  1. In a model, right-click a signal and select Add Conditional Breakpoint.

  2. In the Add Conditional Breakpoint dialog box, from the drop-down list, select the condition for the signal. For example, select greater than or less than.

  3. Enter the signal value where you want simulation to pause and click OK. For the condition values:

    • Use numeric values. Do not use expressions.

    • Do not use NaN.

    The affected signal line displays a conditional breakpoint icon: .

  4. Click the breakpoint to view and edit all conditions set for the signal.

  5. Simulate the model and notice that the model pauses as simulation steps through the conditional breakpoints.

Conditional Breakpoints Limitations

  • You can set conditional breakpoints only on real scalar signals of these data types:

    • double

    • single

    • int

    • bool

    • fixed point (based on the converted double value)

  • You cannot set conditional breakpoints (or port value display labels) on non-Simulink® signals, such as Simscape or SimEvents® signals.

  • Conditional breakpoints also have the limitations that port value display have(Port Value Display Limitations).

Observe Conditional Breakpoint Values

To observe a conditional breakpoint value of a block signal, use data tips to display block port values. You can add data tips before or after you add conditional breakpoints.

  1. Enable the value display for a signal. Right-click the signal line that has a conditional breakpoint and select Show Value Label of Selected Port.

    The data tip for the value display appears.

  2. Simulate the model and observe the conditional breakpoint and data tip when the simulation triggers the breakpoint.

Related Examples

More About

Was this topic helpful?