To compute a continuous state, you must determine its rate of
change, or derivative. You can represent this information using local variables
that update in continuous time. In a Stateflow® chart, continuous-time
variables are always
double type. You cannot change
the type, but you can change the size.
For each continuous variable you define, a Stateflow chart
implicitly creates a variable to represent its time derivative. A
chart denotes time derivative variables as variable_name
For example, the time derivative of continuous variable
You can write to the time derivative variable in the
of a state. The time derivative variable does not appear in the Model
You should not explicitly define
variables with the suffix
Follow these rules when defining and using continuous-time variables:
Scope can be
Define continuous-time variables at the chart level or below in the Stateflow hierarchy.
Expose continuous state by assigning the local variable to a Stateflow output (see Expose Continuous States to a Simulink Model).
To define continuous-time variables, follow these steps:
Configure your chart to update in continuous time, as described in Configure a Stateflow Chart to Update in Continuous Time.
Add local data to your chart in the Stateflow Editor or Model Explorer.
In the properties dialog box for your local data,
set Update Method to
In this example, the chart automatically creates the variable
represent the time derivative of this data.
Note: When you set a variable to update in continuous time, you cannot bind that data to a Simulink® signal.
In a Stateflow chart, you represent continuous state using
local variables, not inputs or outputs (see Purpose of Continuous-Time Variables). To expose the continuous
states to a Simulink model, you must explicitly assign the local
variables to Stateflow outputs in the
of the state. For examples, see Model a Bouncing Ball in Continuous Time.