Define Continuous-Time Variables

Purpose of Continuous-Time Variables

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.

Implicit Time Derivatives

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_dot. For example, the time derivative of continuous variable x is x_dot. You can write to the time derivative variable in the during action of a state. The time derivative variable does not appear in the Model Explorer.


Do not explicitly define variables with the suffix _dot in a chart.

Rules for Using Continuous-Time Variables

When defining and using continuous-time variables, follow these rules:

  • Scope can be Local or Output.

  • 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).

How to Define Continuous-Time Variables

  1. Configure your chart to update in continuous time, as described in Configure a Stateflow Chart to Update in Continuous Time.

  2. Add local data to your chart in the Stateflow Editor or Model Explorer.

  3. In the properties dialog box for your local data, set Update Method to Continuous.

    In this example, the chart automatically creates the variable mydata_dot to represent the time derivative of this data. When you set a variable to update in continuous time, you cannot bind that data to a Simulink® signal.

Expose Continuous States to a Simulink Model

In a Stateflow chart, you represent continuous state by using local variables rather than 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 during action of the state. For an example, see Model a Bouncing Ball in Continuous Time.

Was this topic helpful?