Compare strings (case insensitive)
TF = strcmpi(string,string)
TF = strcmpi(string,cellstr)
TF = strcmpi(cellstr,cellstr)
compares
two strings for equality, ignoring any differences in letter case.
The strings are considered to be equal if the size and content of
each are the same. The function returns a scalar logical 1 for equality,
or scalar logical 0 for inequality.TF
= strcmpi(string
,string
)
compares
a string with each element of a cell array of strings, ignoring letter
case. The function returns a logical array the same size as the TF
= strcmpi(string
,cellstr
)cellstr
input
in which logical 1 represents equality. The order of the input arguments
is not important.
compares
each element of one cell array of strings with the same element of
the other, ignoring letter case. The function returns a logical array
the same size as the input arrays.TF
= strcmpi(cellstr
,cellstr
)

A single character string or nby1 array of strings. 

A cell array of strings. 

When both inputs are character arrays, When either or both inputs are a cell array of strings, 
Perform a simple caseinsensitive comparison of two strings:
strcmpi('Yes', 'No') ans = 0 strcmpi('Yes', 'yes') ans = 1
Create two cell arrays of strings and call strcmpi
to
compare them:
A = {'Handle Graphics', 'Statistics'; ... ' Toolboxes', 'MathWorks'}; B = {'Handle Graphics', 'Signal Processing'; ... 'Toolboxes', 'MATHWORKS'};
match = strcmpi(A, B) match = 1 0 0 1
The result of comparing the two cell arrays is:
match{1,1}
is 1 because "Handle
Graphics" in A{1,1}
matches the same text
in B{1,1}
.
match{1,2}
is 0 because "Statistics"
in A{1,2}
does not match "Signal Processing"
in B{1,2}
.
match{2,1}
is 0 because " Toolboxes", in A{2,1}
contains
leading space characters that are not in B{2,1}
.
match{2,2}
is 1 because even though
"MathWorks" in A{2,2}
uses different
letter case than "MATHWORKS" in B{2,2}
, strcmpi
performs
the comparison without sensitivity to letter case.