This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

before

Control chart execution with the before operator

Syntax

before(n,E)
before(n,time_unit)

Description

example

before(n,E) returns true if the base event E has occurred fewer than n times since activation of the associated state. Otherwise, the operator returns false.

In a chart with no input events, before(n,tick) or before(n,wakeup) returns true if the chart has woken up fewer than n times since activation of the associated state.

The before operator resets the counter for E to 0 each time the associated state reactivates.

example

before(n,time_unit) returns true if fewer than n units of simulation time have elapsed since activation of the associated state. Otherwise, the operator returns false. Specify time_unit as seconds (sec), milliseconds (msec), or microseconds (usec).

The before operator resets the counter for sec, msec, and usec to 0 each time the associated state reactivates.

Examples

expand all

The temp variable increments once per CLK cycle until the state reaches the MAX limit.

on before(MAX,CLK): temp++;

A transition out of the associated state occurs only on broadcast of a ROTATE event, but no later than 10 CLK cycles after activation of the state.

ROTATE[before(10,CLK)]

If the variable temp exceeds 75 and fewer than 12.34 seconds have elapsed since activation of the state, a transition out of the associated state occurs.

[temp > 75 && before(12.34,sec)]

Tips

  • You can use quotation marks to enclose the keywords 'tick', 'wakeup', 'sec', 'msec', and 'usec'. For example, before(5,'tick') is equivalent to before(5,tick).

Introduced in R2014b