Main Content

matches

Determine if two strings match in Requirements Table block

Since R2022b

Description

tf = matches(str1,str2) compares the strings str1 and str2. The operator returns 1 (true) if the strings are identical, and returns 0 (false) otherwise. Use this operator in the Requirements Table block.

example

tf = matches(str1,str2,IgnoreCase=true) compares strings str1 and str2, ignoring any differences in letter case.

example

Examples

expand all

In a Requirements Table block, create a requirement that checks if the string "Hello, world!" matches the string "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!".

In a Requirements Table block, create a requirement that checks if the string "Hello, world!" matches the string "hello, World!" regardless of case.

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.

Input Arguments

expand all

Input strings, specified as string scalars. Enclose literal string with double quotes.

Example: "Hello"

Data Types: string

Limitations

  • This operator does not support the use of Simulink.Bus object fields.

Version History

Introduced in R2022b