Store Continuous State Information in Local Variables
To compute a continuous state, you must determine its time derivative. You can represent this information by using local variables that are updated in continuous time. Continuous-time simulation is supported only in Stateflow® charts in Simulink® models. For more information, see Continuous-Time Modeling in Stateflow.
Define Continuous-Time Variables
Configure the chart to update in continuous time, as described in Configure a Stateflow Chart for Continuous-Time Simulation.
Add a data object to your chart, as described in Add Stateflow Data.
Set the Scope property for the data object to
Local
.Set the Update Method property for the data object to
Continuous
.
In a Stateflow chart, continuous-time variables always have type
double
.
Compute Implicit Time Derivatives
For each continuous-time variable, Stateflow implicitly creates a variable to represent its time derivative. A
chart denotes time derivative variables as
variable_name_dot
. For example,
data_dot
represents the time derivative of a continuous
variable data
. You can write to the time derivative variable in
the during
action of a state. The time derivative variable does
not appear in the Symbols pane or in the Model Explorer.
Note
Do not explicitly define variables with the suffix _dot
in
a chart configured for continuous-time simulation.
Expose Continuous State to a Simulink Model
In a Stateflow chart, you represent the continuous state by using local variables
rather than inputs or outputs. To expose the continuous state to a Simulink model, you must explicitly assign the local variables to Stateflow outputs in the during
action of a state.
Guidelines for Continuous-Time Variables
Scope for continuous-time variables can be
Local
orOutput
.Define continuous-time variables at the chart level or below in the Stateflow hierarchy.
Expose the continuous state of a chart by assigning the local continuous-time variable to a Stateflow output.