| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Stateflow |
| Contents | Index |
| Learn more about Stateflow |
| On this page… |
|---|
The Simulink Model and the Stateflow Machine Overview of Defining Stateflow Block Interfaces to Simulink Models |
A Stateflow chart functions as a finite state machine within a Simulink model. The Stateflow machine is the collection of Stateflow blocks in a Simulink model. The Simulink model and the Stateflow machine work seamlessly together. Running a simulation automatically executes both the Simulink blocks and the Stateflow charts of the model.
A Simulink model can consist of combinations of Simulink blocks, toolbox blocks, and Stateflow blocks (charts). A chart consists of graphical objects (states, boxes, functions, notes, transitions, connective junctions, and history junctions) and nongraphical objects (events, data, and targets).
There is a one-to-one correspondence between the Simulink model and the Stateflow machine. Each Stateflow block in the Simulink model appears as a single Stateflow chart. Each Stateflow machine has its own object hierarchy. The Stateflow machine is the highest level in the Stateflow hierarchy. The object hierarchy beneath the Stateflow machine consists of combinations of graphical and nongraphical objects. See Stateflow Hierarchy of Objects.
Each Stateflow block corresponds to a single Stateflow chart. The Stateflow block interfaces to its Simulink model. The Stateflow block can interface to code sources external to the Simulink model (data, events, custom code).
Stateflow charts are event-driven. Events can be local to the Stateflow block or can propagate to and from the Simulink model. Data can be local to the Stateflow block or can pass to and from the Simulink model and external code sources.
Defining the interface for a Stateflow block can involve some or all these tasks:
Defining the Stateflow block update method
Defining Output to Simulink events
Adding and defining nonlocal events and nonlocal data within the Stateflow chart
Defining relationships with any external sources
In the following example, the Simulink model titled sf_intro_example consists of a Sine Wave block, a Scope block, and a single Stateflow block, titled On_off.

For more information, see Using Input Events to Activate a Stateflow Chart and Defining Interfaces to Simulink Models and the MATLAB Workspace.
![]() | Finite State Machine Concepts | Stateflow Chart Objects | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |