Main Content


Compare first n characters of strings (case insensitive)



tf = strncmpi(s1,s2,n) compares up to n characters of s1 and s2, ignoring any differences in letter case. The function returns 1 (true) if the two are identical and 0 (false) otherwise. Text is considered identical if the content of each is the same up to the end or the first n characters, whichever comes first, ignoring case.


The operator strncmpi is supported only in Stateflow® charts that use MATLAB® as the action language.


expand all

Return 1(true) if the two strings are identical, ignoring case.

h = "Hello, world!"
h2 = "Hello, World!!!!!!!!!!!!"
x = strncmp(h,h2,13)
x2 = strncmpi(h,h2,13)

Stateflow chart that uses the srtncmpi operator in a state.

Results from stateflow chart that uses the strncmpi operator in a state.


Version History

Introduced in R2021b