Main Content

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

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 中推出

另请参阅

| | |