Main Content

本页采用了机器翻译。点击此处可查看英文原文。

getPrevious, prev

Requirements Table模块中数据的先前值

自 R2022a 起

描述

示例

z = getPrevious(u) 返回前一个时间步的数据值。该运算符仅在 Requirements Table模块中起作用。

z = prev(u) 是执行 getPrevious(u) 的另一种方法。

输入参数

全部展开

数据,指定为Requirements Table模块中定义的数据。u必须是输入或输出数据。您必须在属性检查器中为 u 指定一个初始值。有关更多信息,请参阅 在 Requirements Table 模块中定义数据

输出参量

全部展开

前一时间步的值,以与 u 相同的数据类型的值返回。

示例

全部展开

在开始时,将 y 设置为 0 相等。开始时间结束后,调用上一个时间步的预条件中的输入数据u的值。一个需求检查 u 的先前值是否大于或等于当前值,另一个需求检查先前值是否小于当前值。该模块为输出数据 y 分配不同的值。

This image shows a Requirements table that changes the output action depending on the previous value of the block input. If the block input previous value is greater than or equal to the current value, the block outputs 1. Otherwise, the block outputs 2. At the start time, the block outputs 0.

提示

  • 您只能在需求选项卡中使用此运算符。

版本历史记录

在 R2022a 中推出