This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Syntax for States and Transitions

Express chart behavior by using actions and conditions

Control the execution of your Stateflow® chart by specifying when transitions between states occur and when actions are executed. Synchronize state execution by broadcasting events. Detect changes in data values and check which states are active during chart execution.


ChartImplement control logic with finite state machine

Stateflow Syntax

expand all

Change Detection

hasChangedDetect change in data since last time step
hasChangedFromDetect change in data from specified value
hasChangedToDetect change in data to specified value

Temporal Logic

afterControl chart execution with the after operator
atControl chart execution with the at operator
beforeControl chart execution with the before operator
countControl chart execution with the count operator
durationControl chart execution with the duration operator
elapsedControl chart execution with the elapsed operator
everyControl chart execution with the every operator
temporalCountControl chart execution with the temporalCount operator


State Action Types

Specify actions to execute when states are active.

Transition Action Types

Add triggers, conditions, and actions to transitions.

Eliminate Redundant Code by Combining State Actions

Combine entry, during, and exit actions in a state.

Control Function-Call Subsystems by Using bind Actions

Bind a function-call output event to the activity of a state.

Supported Operations for Chart Data

Perform mathematical computations in Stateflow charts.

Supported Symbols in Actions

Special symbols available for state and transition actions.

Call Extrinsic MATLAB Functions in Stateflow Charts

Access MATLAB® functions that are not supported for code generation.

Access MATLAB Functions and Workspace Data in C Charts

Call built-in MATLAB functions by using the ml operator.

Call C Library Functions in C Charts

Access C functions in state and transition labels.

Check State Activity by Using the in Operator

Determine if a state is active during chart execution.

Detect Changes in Data Values

Define chart behavior when data changes value.

Control Chart Execution by Using Temporal Logic

Use event-based and absolute-time temporal logic operators.

Define Chart Behavior by Using Implicit Events

Trigger chart actions by changes in data values and state activity.

Control Oscillations by Using the duration Operator

Simplify debouncing logic in charts that have transient signals.

Count Events by Using the temporalCount Operator

Count occurrences of explicit and implicit events.

Related Information

Featured Examples