选择之前编写好的用例,Excel用例格式遵循如下第一附图的格式
① 第一列为仿真步长时间,单位与simulink中设置一致,默认为s
② 第二列为对应时间下的数值,不允许出现中文注释以及表头等其它符号
③ 可以使用不同工作表管理模型需要仿真的变量,实例模型有两个输入和两个输出,所以Test Case 工作簿里一共4个工作表,分别对应两个输入及两个输出;
④ 模型仿真出来的数据可以导回到Excel中,所以建议使用Excel管理所有变量的逻辑关系(如下面第二附图为本人管理模型的逻辑表格)
旋转模块:选中模块后,右键“Rotate&Flip”。也可快捷键“Ctrl+R”
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的输出结果: