strncmpi
Performs a case-insensitive comparison of the first n characters of x1 with x2. Returns 1 if the characters compared are identical and 0 otherwise.
Syntax
R = strncmpi(x1, x2, n)
Inputs
- x1
- If x1 is a cell, it should either have a size of 1 or match the size of x2.
- x2
- If x2 is a cell, it should either have a size of 1 or match the size of x1.
- n
- Number of characters to match for a case-insensitive comparison.
Outputs
- R
- Type: logical | mat
Examples
String case-insensitive
comparison:
R = strncmpi('STRING1', 'str123456', 3)
R = 1
String-cell array case-insensitive
comparison:
R = strncmpi('string1', {'This', 'is', 'STR123456'}, 3)
R = [Matrix] 1 x 3
0 0 1
Comments
If x1 and x2 are both of type cell, their sizes must be identical or one of them should have just one element. R will be a matrix if either x1 or x2 is of type cell.