Main Content

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

strncmpi

比较 Requirements Table 模块中字符串的前 N 个字符(不区分大小写)

自 R2022b 起

描述

示例

tf = strncmpi(str1,str2,n) 比较 str1str2 中最多 n 个字符,忽略大小写。如果字符串相同,则运算符返回 1 (true),否则返回 0 (false)。在 Requirements Table模块中使用此运算符。

示例

全部展开

Requirements Table模块中,创建一个需求,检查字符串 "Hello, world!" 是否与字符串 "hello, World!!!!!!!!!!!!" 的前十三个字符匹配(忽略大小写)。

y = strncmpi("Hello, world!","hello, World!!!!!!!!!!!!",13)

This example shows a requirement that checks if the string "Hello, world!" matches the first thirteen characters of the string "hello, World!!!!!!!!!!!!", ignoring case.

输入参数

全部展开

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

示例: "Hello"

数据类型: string

从每个字符串的开头开始检查的字符数,指定为正整数。

数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

限制

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

版本历史记录

在 R2022b 中推出

另请参阅

| | |