Main Content

count

Chart executions during which condition is valid

Syntax

Description

example

count(C)returns the number of times that the chart has woken up since the conditional expressionCbecametrueand the associated state became active.

Examples

expand all

反式ition out of the associated state when the variablexhas been greater than or equal to 2 for longer than five chart executions.

[count(x>=2) > 5]

Stateflow chart that uses the count operator in a transition.

Store the number of chart executions since the variablexbecame greater than 5.

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

Stateflow chart that uses the count operator in a state.

Tips

  • The Stateflow®chart resets the value of thecountoperator if the conditional expression becomesfalse或者相关的状态变得不活跃。

  • When a chart in a Simulink®model does not have input events, the value ofcountdepends on the step size. Changing the solver or step size for the model affects the results produced by thecountoperator.

  • To ensure that your Stateflow chart simulates without error, do not use count in these objects:

    • Continuous time charts

    • Graphical, MATLAB®, or Simulink functions

    • Simulink based states

    • 反式itions that can be reached from multiple states

    • Default transitions

Version History

Introduced in R2019a