Stateflow User's Guide Previous page   Next Page

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:

  1. At the MATLAB prompt, enter the following command:
  1. An untitled Simulink model with a Stateflow block appears as shown.

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

  1. This makes room for the blocks you add in the steps that follow.

  1. In the Simulink window, from the View menu, select Library browser.
  1. The Simulink Library Browser window opens with the Simulink node expanded.

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

  1. 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.
  2. 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.
  1. Your model should now have the following appearance:

  1. In the Simulink model window, double-click the top Constant block.
  2. In the resulting Block Parameters dialog, change the Constant value field to 1 and select OK to close the dialog.
  3. In the Simulink model window, from the Simulation menu, select Simulation Parameters.
  1. The Simulation Parameters dialog opens.

  1. In the resulting Simulation Parameters dialog,
  2. Click OK to accept these values and close the Simulation Parameters dialog.
  3. From the Simulink File menu, select Save As and save the model as first_truth_table.mdl.

Previous page  Building a Simulink Model with a Stateflow Truth Table Creating a Stateflow Truth Table Next page

© 1994-2005 The MathWorks, Inc.