Main Content

Simulink 模型中将需求正式化

使用 Requirements Table 模块在仿真之前和仿真期间计算逻辑

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

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

模块

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

函数

全部展开

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

对象

全部展开

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在“需求”选项卡中显示列

运算符

全部展开

时序逻辑

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模块中将字符串转换为大写
reverseRequirements Table模块中字符串中字符的反转顺序
strip从 Requirements Table模块中的字符串中删除前导字符和尾随字符
strtrim从 Requirements Table模块中的字符串中删除前导和尾随空格

比较字符串

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

主题

创建和管理需求

配置需求数据

测试具有需求的模型

疑难解答

调试 Requirements Table 模块

在仿真期间调试Requirements Table模块需求。 (自 R2023a 起)