Stateflow    

Creating a Stateflow Chart

Charts contain a Stateflow diagram that you build with Stateflow objects. You create charts by adding them to a Simulink system. Create a Stateflow chart in a Simulink system with the following steps:

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

  1. 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.

  1. Open the chart by double-clicking the Chart block.
  1. Stateflow opens the empty chart in a Stateflow editor window.

  1. Use the Stateflow editor to draw a Stateflow chart diagram.
  1. See Using the Stateflow Editor and the remaining sections in this chapter for more information on how to draw Stateflow diagrams.

Once you have constructed a Stateflow diagram, continue with the remaining steps to integrate your chart into its Simulink model:

  1. Specify an update method for the chart.
  1. You set the update method for a chart by setting the Update Method field in the properties dialog for the chart. This value determines when and how often the chart is called during the execution of the Simulink model that calls this chart. See Specifying Chart Properties.

  1. Interface the chart to other blocks in your Stateflow model, using events and data.
  1. See Defining Events and Data and Defining Stateflow Interfaces for more information.

  1. Rename and save the model chart by selecting Save Model As from the Stateflow editor menu or Save As from the Simulink menu.


  Working with Charts Using the Stateflow Editor