Stateflow User's Guide Previous page   Next Page
Stateflow

A version of a finite state machine for controlling a physical plant

Library

Stateflow

Description


A finite state machine is a representation of an event-driven (reactive) system. In an event-driven system, the system responds by making a transition from one state (mode) to another prescribed state in response to an event, provided that the condition defining the change is true.

A Stateflow diagram is a graphical representation of a finite state machine, where states and transitions form the basic building blocks of the system. You can also represent flow (stateless) diagrams using Stateflow. Stateflow provides a block that you include in a Simulink model.

Stateflow charts are usually used to control a physical plant in response to events such as a temperature or pressure sensor, or clock or user-driven events. For example, you can use a state machine to represent a car's automatic transmission. The transmission has a number of operating states: park, reverse, neutral, drive, and low. As the driver shifts from one position to another the system makes a transition from one state to another, for example, from park to reverse.

The following diagram shows a simple Simulink model that has a Stateflow block named Chart (default) that responds to input from a manual switch:

If you double-click the Stateflow block in Simulink, the Stateflow diagram that programs the Stateflow block appears in the Stateflow diagram editor window.

During simulation of the Simulink model, you can interactively debug Stateflow diagrams with animated diagrams. Stateflow diagrams generate efficient C code for simulation, and also for Real-Time Workshop, and custom targets, that is suitable for embedded environments.

For an introduction to using Stateflow in Simulink models, see Introduction to Stateflow.

Data Type Support

The Stateflow block accepts inputs of any type including two-dimensional matrices and fixed-point data. Floating-point inputs are passed through the block unchanged. Boolean inputs are treated as uint8 signals.

For a discussion on the variable types supported by Embedded MATLAB functions in Simulink, refer to Data Types Supported by Simulink in the Using Simulink documentation.

You can declare local data of any type or size.

Parameters and Dialog Box

Characteristics

Direct Feedthrough
Yes
Sample Time
Specified in the Sample time parameter
Scalar Expansion
N/A
Dimensionalized
Yes
Zero Crossing
No


Previous page  The Stateflow Block Semantic Rules Summary Next page

© 1994-2005 The MathWorks, Inc.