Main Content

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

hasChanged

检测自 Requirements Table模块中上一步以来数据的变化

自 R2022a 起

描述

示例

如果当前时间步开始时 data 的值与上一时间步开始时 data 的值不同,则 tf = hasChanged(data) 返回 1 (true)。否则,运算符返回 0 (false)。在 Requirements Table模块中使用此运算符。

示例

全部展开

如果输入数据 M 自上一个时间步以来发生了变化,则将输出数据 a 设置为 1。否则,将 a 设置为 0

Requirements Table block that uses the hasChanged operator to determine the value of output data.

如果输入数据 M 第 1 行第 3 列中的元素自上一个时间步以来发生了变化,则将输出数据 a 设置为 1。否则,将 a 设置为 0

Requirements Table block that uses the hasChanged operator to determine the value of output data.

如果结构体struct 的某个字段自上一个时间步以来值发生了改变,则将输出数据 a 设置为 1。否则,将 a 设置为 0

Requirements Table block that uses the hasChanged operator to determine the value of output data.

如果字段 struct.field 自上一个时间步以来值发生了变化,则将输出数据 a 设置为 1。否则,将 a 设置为 0

Requirements Table block that uses the hasChanged operator to determine the value of output data.

输入参数

全部展开

Requirements Table模块中定义的数据,指定为:

  • 标量

  • 矩阵或矩阵元素

  • 结构体或结构体中的字段

  • 结构体字段或矩阵元素的有效组合

请参阅在 Requirements Table 模块中定义数据

如果 data 是一个矩阵,则当运算符检测到 data 的某个元素发生变化时,它将返回 true。您还可以使用数字或整数表达式来索引矩阵的元素。

如果 data 是一个结构体,则当运算符检测到 data 的某个字段发生变化时,它将返回 true。您还可以使用点符号来索引结构体中的字段。

您必须为 data 指定一个初始值。有关更多信息,请参阅 在 Requirements Table 模块中定义数据

参量data 不能是非平凡表达式或自定义代码变量。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | string | fi | enumerated | bus

提示

  • 如果 Requirements Table模块写入指定数据但不更改值,则 hasChanged 运算符返回 false

版本历史记录

在 R2022a 中推出