Main Content

strcmp

Compare strings in Requirements Table block (case sensitive)

Since R2022b

Description

example

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

Examples

expand all

In a Requirements Table block, create a requirement that checks if the strings "abc" and "abc" are equal.

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

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

You can also compare and sort string with relational operators. Use == to determine two strings are equal.

"abc" == "abc"

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

Use ~= to determine if two strings are not equal.

"abc" ~= "abcd"

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

Input Arguments

Version History

Introduced in R2022b