| Stateflow User's Guide | ![]() |
Simulating a Bound Function-Call Subsystem
To see the control that a state can have over the function-call subsystem whose trigger event it binds, begin simulating the example model in Binding a Function-Call Subsystem. For the purposes of display, the simulation parameters for this model specify a fixed-step solver with a fixed-step size of 1. Take note of model behavior in the following steps, which record the simulating Stateflow diagram and the output of the subsystem.
A becomes active, it executes its bind and entry actions. The binding action, bind:E, binds event E to state A. This enables the function-call subsystem and resets its state variables to 0.
State A also executes its entry action, en:E, which sends an event E to trigger the function-call subsystem and execute its block diagram. The block diagram increments a count by 1 each time using a Unit Delay block. Since the previous content of the Unit Delay block is 0 after the reset, the starting output point is 0 and the current value of 1 is held for the next call to the subsystem.
B, after(10, tick), allows the transition to be taken only after ten update events are received. This means that for the second update, the during action of state A, du:E, is executed, which sends an event to trigger the function-call subsystem. The held content of the Unit Delay block, 1, is output to the scope as shown.
The subsystem also adds 1 to the held value to produce the value 2, which is held by the Unit Delay block for the next triggered execution.
B active. Since the binding state A is no longer active, the function-call subsystem is disabled, and its output drops to 0.
| Binding a Function-Call Subsystem | Using Stateflow Logic with Binding | ![]() |
© 1994-2005 The MathWorks, Inc.