| Contents | Index |
| On this page… |
|---|
Extends the Capabilities of Traditional State Charts |
The Stateflow product is an interactive graphical design tool that works with Simulink software to model and simulate event-driven systems, also called reactive systems. Event-driven systems transition from one operating mode to another in response to events and conditions. These systems are often used to model logic for dynamically controlling a physical device such as a fan, motor, or pump. Event-driven systems can be modeled as finite-state machines.
Finite-state machines represent operating modes as states. For example, a house fan can have states such as High, Medium, Low, and Off. To construct finite-state machines, Stateflow software provides graphical objects that you can drag and drop from a design palette to create charts in which a series of transitions directs a flow of logic from one state to another. You can also add:
Input and output data
Events for triggering Stateflow charts
Actions and conditions, which you can attach to states and transitions to further define the behavior of the Stateflow chart
With traditional state charts, you can specify hierarchy and model parallel states, among other capabilities. With the Stateflow product, you can extend the capabilities of traditional state charts by:
Defining functions in the following ways:
Graphically, using flow diagram constructs that model logic patterns and iterative loops
Procedurally, using MATLAB code
In tabular form, using truth tables
Using directed-event broadcasts to synchronize activity of parallel states
Using temporal logic to schedule events
Defining vector, matrix, and fixed-point data types
Modeling continuous or discrete systems
Integrating custom C code that you can call from a chart
The product provides the following capabilities for testing a design:
Animation of state charts so that you can watch the logic transition from state to state or flow from one branch to another during simulation
A debugger that enables you to set breakpoints and pause simulation at key points
Stateflow software performs simulation by generating a C code implementation of the Stateflow chart. The simulation code is generated from a simulation target, which you can learn more about in Simulating the Chart.
You can also generate portable C code from Stateflow charts automatically using Simulink® Coder™ code generation software (available separately). The Simulink Coder product also generates C code for Simulink models that include Stateflow charts.
In addition to C code generation, you can generate code from Stateflow charts in the following languages:
HDL, using Simulink® HDL Coder™ software
PLC, using Simulink® PLC Coder™ software
![]() | Introduction to the Stateflow Product | What Does a Stateflow Chart Look Like? | ![]() |

Learn how engineers use Stateflow to model state machines in their Simulink models.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |