| Using Simulink | ![]() |
Setting Conditional Breakpoints
You can use either the Break on conditions panel of the debugger's Breakpoints pane
or the following commands (in command-line mode) to set conditional breakpoints.
| Command |
Causes Simulation to Stop |
|
At a simulation time step |
minor |
At methods invoked in minor time steps |
|
At the occurrence of an underflow or overflow (NaN) or infinite (Inf) value |
|
When the simulation reaches the state that determines the simulation step size |
|
When a zero crossing occurs between simulation time steps |
Setting Breakpoints at Time Steps
To set a breakpoint at a time step, enter a time in the debugger's Break at time field (GUI mode) or enter the time using the tbreak command. This causes the debugger to stop the simulation at the Outputs.Major method of the model at the first time step that follows the specified time. For example, starting vdp in debug mode and entering the commands
causes the debugger to halt the simulation at the vdp.Outputs.Major method of time step 2.078 as indicated by the output of the continue command.
%-------------------------------------------------------------- % [TM = 2.078784598291364 ] vdp.Outputs.Major (sldebug @18):
Breaking on Nonfinite Values
Selecting the debugger's NaN values option or entering the nanbreak command causes the simulation to stop when a computed value is infinite or outside the range of values that can be represented by the machine running the simulation. This option is useful for pinpointing computational errors in a Simulink model.
Breaking on Step-Size Limiting Steps
Selecting the Step size limited by state option or entering the xbreak command causes the debugger to stop the simulation when the model uses a variable-step solver and the solver encounters a state that limits the size of the steps that it can take. This command is useful in debugging models that appear to require an excessive number of simulation time steps to solve.
Breaking at Zero Crossings
Selecting the Zero crossings option or entering the zcbreak command causes the simulation to halt when Simulink detects a nonsampled zero crossing in a model that includes blocks where zero crossings can arise. After halting, Simulink displays the location in the model, the time, and the type (rising or falling) of the zero crossing. For example, setting a zero-crossing break at the start of execution of the zeroxing demo model,
sldebug zeroxing %-------------------------------------------------------------- % [TM = 0 ] zeroxing.Simulate (sldebug @0): zcbreak Break at zero crossing events : enabled
results in a rising zero-crossing break at
[Tz = 0.2 ] [Hz = 0 ] Detected 2 Zero Crossing Events 0:5:1R, 0:5:2R %-------------------------------------------------------------- % [Tm = 0.4 ] zeroxing.ZeroCrossingDetectionLoop (sldebug @45):
If a model does not include blocks capable of producing nonsampled zero crossings, the command prints a message advising you of this fact.
Breaking in Minor Time Steps
To break at invocations of a block's methods in minor time steps, select the Minor time steps option on the debugger's Break on conditions panel or enter minor at the debugger command prompt.
Note
For this option to take effect, you must previously or subsequently set breakpoints on all the block's methods, using either the Breakpoint button on the debugger's toolbar or the break gcb or bafter gcb command. This option has no effect on breakpoints set on specific invocations of a block's methods set in either the Simulation Loop pane or via the break/bafter m:id commands.
|
| Setting Breakpoints | Displaying Information About the Simulation | ![]() |
© 1994-2005 The MathWorks, Inc.