Guy and Seth on Simulink

New options for debugging in R2012b 1

Posted by Guy Rouleau,

Today I want to highlight R2012b features very useful when debugging a model.

Using the simulation stepping and conditional breakpoints, you should be able to run your simulation up to a certain point and move back and forth in time around this point to test things without re-running the entire simulation.

Simulation Stepper

You probably noticed that the Simulink toolbar now has 2 new buttons to step forward and backward:

Stepper toolbar

To use this feature efficiently, I think it is important to understand how it works.

On one side, the next step button is obvious. Pushing it makes the simulation move forward by one step.

Moving backward involves a bit more. Just like with your DVR (or VCR as I first wrote), to go backward data must be recorded. Under the hood, the simulation stepper saves snapshots of the simulation using SimState.

When you click the previous step button for the first time, a dialog opens:

Stepper configuration dialog

In this dialog, you can specify how many previous snapshots are saved and the number of major steps between those snapshots. Based on the size of your model, you need to choose numbers that avoid using too much memory or saving snapshots too frequently that might slow down your simulation.

Breakpoints

Before stepping backward, you first need to run and then pause the simulation. This can be done with breakpoints.

To pause at a specific simulation time, you can use the dialog shown above.

What is more interesting is to break based on signals values. When you right-click on a signal line, you can add conditional breakpoints:

Stepper toolbar

You define the conditions for the breakpoint:

Stepper toolbar

Of course, you can add multiple conditions for the same signal. Once you added all your breakpoints, you can manage them by clicking on the breakpoint icon next to the line:

Stepper toolbar

Now it's your turn

Look at the documentation for a detailed example of Stepping Through a Simulation and let us know what you think of this new debugging technique by leaving a comment here.

1 CommentsOldest to Newest

Hello all,

I’d like to mention an Enhancement Request I recently made. My proposal is to enable the user to be able to move backward/forward a spoecified amount of time instead of steps.

How do you think about this proposal?

– Han

Add A Comment

What is 3 + 6?

Preview: hide

These postings are the author's and don't necessarily represent the opinions of MathWorks.