| MATLAB Functions | Help Desk |
strncmp
Compare the firstn characters of two strings
k = strncmp('str1','str2',n)
TF = strncmp(S,T,n)
k = strncmp('str1','str2',n)
returns logical true (1) if the first n characters of the strings str1 and str2 are the same, and returns logical false (0) otherwise. Arguments str1 and str2 may also be cell arrays of strings.
TF = strncmp(S,T,N)
where either S or T is a cell array of strings, returns an array TF the same size as S and T containing 1 for those elements of S and T that match (up to n characters), and 0 otherwise. S and T must be the same size (or one can be a scalar cell). Either one can also be a character array with the right number of rows.
The command strncmp is case sensitive. Any leading and trailing blanks in either of the strings are explicitly included in the comparison.
findstr Find one string within another
strcmp Compare strings
strmatch Find possible matches for a string