Main Content

duration

Time during which condition is valid

Description

example

duration(C) returns the number of seconds since the conditional expression C became true and the associated state became active.

Note

The temporal logic operator duration is not supported in standalone charts in MATLAB®.

Examples

expand all

Transition out of the state when the variable x has been greater than or equal to 0 for longer than 0.1 seconds.

[duration(x>=0) > 0.1]

Stateflow chart that uses the duration operator in a transition.

Store the number of seconds since the variable x became greater than 5.

en,du:
   y = duration(x>5);

Stateflow chart that uses the duration operator in a state.

Tips

  • The Stateflow® chart resets the value of the duration operator if the conditional expression C becomes false or if the associated state becomes inactive.

  • The duration operator does not support conditions that depend on local or output structures. For more information, see Access Bus Signals Through Stateflow Structures.

Introduced in R2017a