Creating a Stateflow® Chart

You build a chart with Stateflow® objects. You create charts by adding them to a Simulink® model. Create a Stateflow chart in a Simulink model with the following steps:

  1. Enter sfnew or stateflow at the MATLAB® command prompt to create a new empty model with a Stateflow chart.

    The stateflow command also displays the Stateflow block library.

    You can drag and drop additional charts in your Simulink system from this library in case you want to create multiple charts in your model. You can also drag and drop new charts into existing systems from the Stateflow library in the Simulink Library Browser. For information on creating your own chart libraries, see Creating Chart Libraries.

  2. Open the chart by double-clicking the Chart block.

    The empty chart appears in the Stateflow Editor.

  3. Open the Chart properties dialog box.

    See Setting Properties for Individual Charts.

  4. In the Chart properties dialog box, select a chart type from the drop-down menu in the State Machine Type field:

    TypeDescription
    ClassicThe default machine type. Provides the full set of Stateflow chart semantics (see Stateflow® Chart Semantics).
    MealyMachine type in which output is a function of inputs and state.
    MooreMachine type in which output is a function only of state.

    Mealy and Moore charts use a subset of Stateflow chart semantics. For more information, see Building Mealy and Moore Charts.

  5. In the Chart properties dialog box, specify an update method for the chart in the Update method field.

    This value determines when and how often the chart is called during the execution of the Simulink model.

  6. Use the Stateflow Editor to draw a Stateflow chart.

    See Using the Stateflow® Editor and the rest of this chapter for more information on how to draw Stateflow charts.

  7. Interface the chart to other blocks in your Simulink model, using events and data.

    See Defining Events, Defining Data, and Defining Interfaces to Simulink® Models and the MATLAB® Workspace for more information.

  8. Rename and save the model by selecting Save Model As from the Stateflow Editor menu or Save As from the Simulink menu.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS