Main Content

matches

Determine if two strings match

Since R2021b

Description

example

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.

example

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

Note

The matches operator is not supported in Stateflow® charts that use C as the action language. For similar functionality, use strcmp.

Examples

expand all

Return a value of 0 (false) because the strings do not match.

str1 = "Hello, world!";
str2 = "hello, World!";
x = matches(str1,str2);

Stateflow chart that uses the lower operator in a state.

Return a value of 1 (true) because the strings match when you ignore case.

str1 = "Hello, world!";
str2 = "hello, World!";
x = matches(str1,str2,IgnoreCase=true);

Stateflow chart that uses the lower operator in a state.

Input Arguments

expand all

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

Example: "Hello"

Limitations

Version History

Introduced in R2021b