strcmpi
Compares text for equality, ignoring letter case.
Category: Language Fundamentals > Data Types
Syntax
tf = strcmpi(s1, s2)
Returns true if the texts are equal apart from case.
Description
strcmpi behaves like strcmp but treats upper and lower case versions of a letter as equal. Length and all other characters, including spaces, must still match exactly.
It is handy for checking option names typed by a user, for example strcmpi(opt, 'yes').
Input arguments
s1, s2- Character vectors, strings, cell arrays or string arrays, with the same rules for scalar expansion as
strcmp.
Output arguments
tf- Logical scalar or array.
Example
Case-insensitive match
strcmpi('Hello', 'hELLO')
strcmpi({'Yes','no'}, 'yes')
Output
ans = logical
1
ans = 1×2 logical array
1 0