主要内容

对需求进行建模和验证

使用 Requirements Table 模块来对需求进行建模和分析,以验证一致性和完整性

通过使用 Requirements Table 模块在运行前和运行时计算逻辑,在 Simulink® 模型中定义形式化需求。使用形式化需求来检查您的模型的输出或执行模块输出。

直接在该模块中、在需求编辑器中或使用 MATLAB® 中的编程命令来配置形式化需求。

使用 Simulink Design Verifier™ 分析形式化需求,确认需求是完整且一致的。在生成测试和验证设定模型之前验证形式化需求。

您还可以通过生成测试在 Requirements Table 模块中验证需求。有关详细信息,请参阅使用测试来验证需求

模块

Requirements Table使用输入条件对形式化需求进行建模 (自 R2022a 起)

函数

全部展开

slreq.modeling.create使用 Requirements Table 模块创建新模型 (自 R2022a 起)
slreq.modeling.find查找 Requirements Table 块 (自 R2022a 起)
slreq.load加载需求集、链接集或 Requirements Table 模块
anyValue抑制 Requirements Table 模块中输出的不完整性问题 (自 R2024a 起)

运算符

全部展开

时序逻辑

durationRequirements Table 模块中条件有效的时间
getPreviousRequirements Table 模块中数据的先前值
isStartup仿真时间是否在 Requirements Table 模块中为 0
tRequirements Table 模块中的仿真已用时间

更改检测

hasChanged检测自 Requirements Table 模块中上一时间步以来数据的变化
hasChangedFrom检测 Requirements Table 模块中指定值的数据变化
hasChangedTo检测 Requirements Table 模块中数据是否变为指定值

创建、串联和转换字符串

str2double在 Requirements Table 模块中将字符串转换为双精度值
string在 Requirements Table 模块中将值转换为字符串
plus连接 Requirements Table 模块中的字符串

确定字符串的属性

isletter确定 Requirements Table 模块中的哪些字符是字母
isspace确定 Requirements Table 模块中哪些字符是空格
isstring确定 Requirements Table 模块中的输入是否为字符串
strlength确定 Requirements Table 模块中字符串的长度
contains在 Requirements Table 模块中确定字符串是否包含子字符串

查找和替换字符串字符

contains在 Requirements Table 模块中确定字符串是否包含子字符串
endsWith确定字符串是否以 Requirements Table 模块中的子字符串结尾
matches确定 Requirements Table 模块中两个字符串是否匹配
replace查找并替换 Requirements Table 模块中的子字符串
replaceBetween替换 Requirements Table 模块中起点和终点之间的子字符串
startsWith在 Requirements Table 模块中确定字符串是否以子字符串开头
strfind在 Requirements Table 模块中查找字符串内的子字符串
strrep查找并替换 Requirements Table 模块中的子字符串

编辑字符串

erase删除 Requirements Table 模块中字符串内的子字符串
eraseBetween删除 Requirements Table 模块中起点和终点之间的子字符串
extractAfter提取 Requirements Table 模块中位置后的子字符串
extractBefore提取 Requirements Table 模块中位置之前的子字符串
insertAfter在 Requirements Table 模块中的子字符串后插入字符串
insertBefore在 Requirements Table 模块中的子字符串前插入字符串
lower在 Requirements Table 模块中将字符串转换为小写
upper在 Requirements Table 模块中将字符串转换为大写
reverse在 Requirements Table 模块中反转字符串中字符的顺序
strip从 Requirements Table 模块中的字符串中删除前导字符和尾随字符
strtrim在 Requirements Table 模块中删除字符串中的前导和尾随空格

比较字符串

matches确定 Requirements Table 模块中两个字符串是否匹配
strcmp在 Requirements Table 模块中比较字符串(区分大小写)
strcmpi比较 Requirements Table 模块中的字符串(不区分大小写)
strncmp比较 Requirements Table 模块中字符串的前 N 个字符(区分大小写)
strncmpi比较 Requirements Table 模块中字符串的前 N 个字符(不区分大小写)

对象

全部展开

RequirementsTable配置 Requirements Table 块 (自 R2022a 起)
Symbol在 Requirements Table 块中配置数据 (自 R2022a 起)
RequirementRowRequirements Table 模块中的需求 (自 R2022a 起)
AssumptionRowRequirements Table 模块中的假设 (自 R2022a 起)

对象函数

全部展开

管理模块数据

addSymbol将数据添加到 Requirements Table 模块
findSymbol检索 Requirements Table 模块中的数据

管理模块行

addAssumptionRow将假设添加到 Requirements Table 模块
addRequirementRow将需求添加到 Requirements Table 模块
addChild将子需求或假设添加到 Requirements Table 模块
getRequirementRows检索 Requirements Table 模块中的需求
getAssumptionRows检索 Requirements Table 模块中的假设
getChildren检索 Requirements Table 模块中的子需求和假设
slreq.getCurrentObject获取需求编辑器、需求浏览器或 Requirements Table 模块中选定的对象
clear清除 Requirements Table 模块中的行
removeRow删除 Requirements Table 模块行

管理模块列

hideAssumptionColumn隐藏假设选项卡中的预条件列
hideRequirementColumn隐藏“需求”选项卡中的列
showAssumptionColumn在“假设”选项卡中显示“预条件”列
showRequirementColumn在“需求”选项卡中显示列

主题

创建需求

定义计算逻辑

配置 Requirements Table 模块的属性

配置数据

验证需求

疑难解答

调试 Requirements Table 模块

通过在仿真过程中使用断点和分析模块数据来调试 Requirements Table 模块。 (自 R2023a 起)

精选示例