Stateflow® 7.1
Product Description
- Introduction and Key Features
- Working with Stateflow
- Creating Stateflow Charts
- Adding Functions
- Executing Stateflow Charts
Adding Functions
With Stateflow you can define and use three types of functions in your chart:
Graphical functions—for graphically programming an algorithm and tracking its behavior during simulation
Embedded MATLAB™ functions— for calling MATLAB functions for data analysis and visualization, and for defining embedded, matrix-oriented algorithms
Truth tables—for specifying functions with combinational logic in a concise, tabular form without drawing flow diagrams
You can call Simulink subsystems like functions from Stateflow. You can also incorporate existing hand-written C code functions into your Stateflow chart.
| Truth table used to implement the logic to select a valid sensor reading in a fault-detection algorithm. Click on image to see enlarged view. |
Specifying Temporal Logic Conditions
Stateflow employs an event-scheduling mechanism that generates accurate and efficient code for event-driven systems. You can use temporal operators (before, after, at, and every) to specify scheduling logic for transition and state activities. These temporal logic conditions respond to counts of Stateflow events, freeing you from the error-prone event-scheduling tasks of handling timers and counters.
Creating Chart Libraries
By creating a chart library in Stateflow, you facilitate chart reuse. For example, when you update a chart in a library, all instances of the chart are automatically updated.
Interfacing with Simulink
You can exchange events and data with Simulink by simply:
- Adding and defining input and output events and data for your Stateflow chart in Model Explorer
- Connecting the Stateflow input and output ports to Simulink blocks
- Defining simulation parameters in Simulink
You can also define an interface between a Stateflow block and code sources external to the Stateflow block and Simulink model. Model Explorer lets you navigate, create, configure, and search all data, events, and attributes of your Stateflow chart, as well as create an interface with Simulink.
| Logic for a fault-tolerant fuel system, defined using several key Stateflow elements. Click on image to see enlarged view. |
Store



