This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Implement control logic with finite state machine




A finite state machine is a representation of an event-driven (reactive) system. In an event-driven system, the system responds to an event by making a transition from one state (mode) to another. This action occurs as long as the condition defining the change is true.

A Stateflow chart is a graphical representation of a finite state machine. States and transitions form the basic elements of the system. You can also represent stateless flow charts.

For example, you can use Stateflow charts to control a physical plant in response to events such as a temperature and pressure sensors, clocks, and user-driven events.

You can also use a state machine to represent the automatic transmission of a car. The transmission has these 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.

A Stateflow Chart can use MATLAB or C as the action language to implement control logic.

This block diagram represents a machine on an assembly line that feeds raw material to other parts of the line. It contains a chart, Feeder, with MATLAB as the action language.

If you double-click the Feeder block in the model, the chart appears.

For a tutorial on this model, see Model Event-Driven System.

Data Type Support

The Chart block accepts input signals of any data type that Simulink® supports, including fixed-point data and enumerated data types. For a description of data types that Simulink supports, refer to the Simulink documentation.

Floating-point inputs pass through the block unchanged. Boolean inputs to charts that use MATLAB as the action language pass directly as Boolean outputs. Boolean inputs to charts that use C as the action language are treated as double type.

You can declare local data of any type or size.


For a description of the block parameters, see the Subsystem block reference page in the Simulink documentation.


Direct Feedthrough

Yes, for Classic and Mealy charts.

No, for Moore charts.

Sample Time

Specified in the Sample time parameter

Scalar Expansion




Zero-Crossing Detection

Yes, if enabled for continuous-time systems.

For more information, see When to Disable Zero-Crossing Detection.

Introduced in R2013b

Was this topic helpful?