elapsed, et
Time since state became active
Syntax
Description
elapsed(
returns the length of time
that has elapsed since the associated state became active.sec
)
et
is an alternative way to execute
elapsed(sec)
.
Note
The expressions elapsed(sec)
and et
are
equivalent to temporalCount(sec)
.
Examples
Tips
In state and transition actions, you can use quotation marks to enclose the keyword
'sec'
. For example,elapsed('sec')
is equivalent toelapsed(sec)
.The Stateflow® chart resets the counter used by the
elapsed
operator each time the associated state reactivates.The timing for absolute-time temporal logic operators depends on the type of Stateflow chart:
Charts in a Simulink® model define temporal logic in terms of simulation time.
Standalone charts in MATLAB® define temporal logic in terms of wall-clock time.
The difference in timing can affect the behavior of a chart. For example, suppose that this chart is executing the
entry
action of stateA
.In a Simulink model, the function call to
f
executes in a single time step and does not contribute to the simulation time. After calling the functionf
, the chart assigns a value of zero toy
.In a standalone chart, the function call to
f
can take several seconds of wall-clock time to complete. After calling the functionf
, the chart assigns the nonzero time that has elapsed since stateA
became active toy
.
Version History
Introduced in R2017a