主要内容

strcmp

在 Requirements Table 模块中比较字符串(区分大小写)

自 R2022b 起

描述

tf = strcmp(str1,str2) 比较字符串 str1str2。此运算符在这两个字符串完全相同时返回 1 (true),否则返回 0 (false)。strcmp 区分大小写。在 Requirements Table 模块中使用此运算符。

示例

示例

全部展开

Requirements Table 模块中,创建一个需求,用于检查字符串 "abc""abc" 是否相等。

y = strcmp("abc","abc")

This example shows a requirement that checks if the strings "abc" and "abc" are equal.

您还可以使用关系运算符比较和排序字符串。使用 == 确定两个字符串是否相等。

"abc" == "abc"

This example shows a requirement that checks if the strings "abc" and "abc" are equal.

使用 ~= 确定两个字符串是否不相等。

"abc" ~= "abcd"

This example shows a requirement that checks if the strings "abc" and "abcd" are not equal.

输入参数

版本历史记录

在 R2022b 中推出

另请参阅

| | |