| Stateflow User's Guide |
 |
Creating a Simulink Model
To execute a truth table, you first need a Simulink model that calls a Stateflow block. Later, you create a Stateflow diagram for the Stateflow block that calls a truth table function. In this topic, you create a Simulink model that calls a Stateflow block with the following procedure:
- At the MATLAB prompt, enter the following command:
- An untitled Simulink model with a Stateflow block appears as shown.

- Click and drag the Stateflow block to the center of the Simulink window as shown.

- This makes room for the blocks you add in the steps that follow.
- In the Simulink window, from the View menu, select Library browser.
- The Simulink Library Browser window opens with the Simulink node expanded.

- Under the Simulink node, select the Sources library.
- The right pane of the Simulink Library Browser window displays the block members of the Sources library.

- From the right pane of the Simulink Library Browser window, click and drag the Constant block to the left of the Stateflow block in the Simulink model.
- Add two more Constant blocks to the left of the Chart block and a Display block (from the Sinks library) to the right of the Chart block.
- Your model should now have the following appearance:

- In the Simulink model window, double-click the top Constant block.
- In the resulting Block Parameters dialog, change the Constant value field to 1 and select OK to close the dialog.
- In the Simulink model window, from the Simulation menu, select Simulation Parameters.
- The Simulation Parameters dialog opens.
- In the resulting Simulation Parameters dialog,
- Leave the Solver Options field set at
Variable-step.
- Change the Stop Time to
inf.
- Click OK to accept these values and close the Simulation Parameters dialog.
- From the Simulink File menu, select Save As and save the model as
first_truth_table.mdl.
| Building a Simulink Model with a Stateflow Truth Table | | Creating a Stateflow Truth Table |  |
© 1994-2005 The MathWorks, Inc.