Main Content

Execution in MATLAB

Execute standalone Stateflow® charts as objects in MATLAB®

Design logic by using state charts and execute that logic as MATLAB programs. Execute and unit test your chart in the Stateflow editor. Control the behavior of user interfaces and data processing applications through your chart.


expand all

Stateflow.exportAsClassExport MATLAB class for standalone chart (Since R2019b)
Stateflow.exportToVersionExport standalone chart for use in previous version of Stateflow (Since R2020a)

Stateflow Syntax

expand all

Change Detection

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

Temporal Logic

afterExecute chart after event broadcast or specified time
atExecute chart at event broadcast or specified time
countNumber of chart executions during which condition is valid
elapsedTime since state became active
everyExecute chart at regular intervals
temporalCountNumber of events, chart executions, or time since state became active



Debug a Standalone Stateflow Chart

Interrupt execution to step through each action in a Stateflow chart.