Stateflow_after计时计数

在Stateflow中可以使用after函数进行计时,计数等操作。具体使用方法可以参考Stateflow的帮助文档:《Stateflow User Guide》。

1 事件计数

语法:

after(n,E)

n是一个正整数或计算结果为正整数值的表达式。E是事件(event)。

Returns true if the event E has occurred at least n times since the associated state became active. Otherwise, the operator returns false.

2 chart计数

语法:

after(n,tick)

n is a positive integer or an expression that evaluates to a positive integer value.

Returns true if the chart has woken up at least n times since the associated state became active. Otherwise, the operator returns false.

The implicit event tick is not supported when a Stateflow chart in a Simulink model has input events. For more information, see “Control Chart Behavior by Using Implicit Events” on page 11-23.

3 计时

语法:

after(n,sec)
after(n,msec)
after(n,usec)

n is a positive real number or an expression that evaluates to a positive real value.

Returns true if at least n units of time have elapsed since the associated state became active. Otherwise, the operator returns
false.

In charts in a Simulink model, specify time in seconds (sec), milliseconds (msec), or microseconds (usec).

In standalone charts in MATLAB, specify time in seconds (sec). The operator creates a MATLAB timer object that generates an implicit event to wake up the chart. MATLAB timer objects are limited to 1 millisecond precision. For more information, see “Events in Standalone Charts” on page 3-53.

案例1:

c的输出结果:

案例2:

c的输出结果:

 

 

 

 

备注:

  1. 仿真步长要小于计时时间的最小步长。
  2. Temporal conditions cannot be used in flow graphs.

参考文献:

《Stateflow User Guide》\rightarrowUse Actions in Charts\rightarrowControl Chart Execution by Using Temporal Logic

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值