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.
You probably noticed that the Simulink toolbar now has 2 new buttons to step forward and backward:
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:
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.
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:
You define the conditions for the breakpoint:
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:
Now it's your turn
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。