Main Content

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

matches

确定 Requirements Table模块中两个字符串是否匹配

自 R2022b 起

描述

示例

tf = matches(str1,str2) 比较字符串 str1str2。如果字符串相同,则运算符返回 1 (true),否则返回 0 (false)。在 Requirements Table模块中使用此运算符。

示例

tf = matches(str1,str2,IgnoreCase=true) 比较字符串 str1str2,忽略字母大小写的差异。

示例

全部展开

Requirements Table模块中,创建一个需求,检查字符串 "Hello, world!" 是否与字符串 "Hello, world!" 匹配。

y = matches("Hello, world!","Hello, world!")

This image shows a requirement that outputs whether the string "Hello, world" matches the substring "Hello, world!".

Requirements Table模块中,创建一个需求,检查字符串 "Hello, world!" 是否与字符串 "hello, World!" 匹配,无论大小写。

y = matches("Hello, world!","hello, World!",IgnoreCase=true)

This image shows a requirement that outputs whether the string "Hello, world" matches the substring "hello, World!" regardless of case.

输入参数

全部展开

输入字符串,指定为字符串标量。将文字字符串用双引号引起来。

示例: "Hello"

数据类型: string

限制

  • 该运算符不支持使用Simulink.Bus对象字段。

版本历史记录

在 R2022b 中推出

另请参阅

| | |