Main Content

duration

Elapsed time since beginning of test step

Description

elapsed_time = duration(condition,timeunits) returns the elapsed time in timeunits for which the condition has been true. The condition is a logical expression. The elapsed_time is reset when the test step is re-entered or when the condition is no longer true. If you omit timeunits, the elapsed time defaults to seconds.

Valid time units are:

  • sec — seconds

  • msec — milliseconds

  • usec — microseconds

Examples

Specify Time Elapsed For a Duration

Specify the duration after 100 msec from the time when x greater than 50 last became true.

duration(x > 50,msec) > 100

Tips

  • duration statements can be used in the Test Sequence and Test Assessment blocks and in Stateflow® charts.

  • In Stateflow charts, duration statements can be associated only with a single state. You cannot use a duration on a transition that has more than one source state connected using a junction.

Introduced in R2015a