every

Control chart execution with the every operator

Syntax

every(n,E)
every(n,time_unit)

Description

example

every(n,E) returns true at every nth occurrence of the base event E since activation of the associated state. Otherwise, the operator returns false.

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

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

example

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

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

Use of every as an absolute-time temporal logic operator is supported only in standalone charts for execution as MATLAB® objects.

Examples

expand all

A status message on appears every 5 CLK cycles after activation of the state.

on every(5,CLK): status('on');

A status message is displayed every 2 seconds after activation of the state.

on every(2,sec): disp('Hello!');

Tips

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

  • Use of every as an absolute-time temporal logic operator is supported only in standalone charts for execution as MATLAB objects. In a Simulink® model, use an outer self-loop transition with the after operator instead. For more information, see Use an Outer Self-Loop Transition with the after Operator to Replace the every Operator.

Introduced in R2014b