Main Content


Compare strings in Stateflow chart (case insensitive)

Since R2021b



tf = strcmpi(str1,str2) compares strings str1 and str2, ignoring differences in letter case. The operator returns 1 (true) if the strings are identical and 0 (false) otherwise.


The operator strcmpi is not supported in Stateflow® charts that use C as the action language.


expand all

Set x to 0 (false) because the strings do not match. Set y to 1 (true) because the strings match when you ignore case.

str1 = "Hello, World!";
str2 = "hello, world!";
x = strcmp(str1,str2);
y = strcmpi(str1,str2);

Stateflow chart that uses the strcmpi operator in a state.

Input Arguments

expand all

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

Example: "Hello"


Version History

Introduced in R2021b