Time since state became active
elapsed( returns the time in seconds
sec) that has elapsed since the activation of the associated
elapsed operator resets the counter for
sec to 0 each time the associated state reactivates.
Store the length of time that the state has been active.
en,du: y = elapsed(sec);
In state and transition actions, you can use quotation marks to enclose the
y = elapsed('sec');
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
action of state
In a Simulink model, the function call to
executes in a single time step and does not contribute to the
simulation time. After calling the function
the chart assigns a value of zero to
In a standalone chart, the function call to
can take several seconds of wall-clock time to complete. After
calling the function
f, the chart assigns the
nonzero time that has elapsed since state
became active to