Documentation |
On this page… |
---|
Purpose of Continuous-Time Variables Rules for Using 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.
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.
Follow these rules when defining and using continuous-time variables:
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).
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 Continuous.
In this example, the chart automatically creates the variable mydata_dot to represent the time derivative of this data.
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 during action of the state. For examples, see Model a Bouncing Ball in Continuous Time.