Transferred from: http://www.cnblogs.com/emanlee/archive/2012/09/13/2683912.html
% string processing
A= ' a '; b= ' b b '; c= ' CCCC '; m= '
% get string length
length (a)
% connects two strings, and the rightmost space of each string is trimmed
d=strcat(a,c)
Length (d)
% joins multiple lines of string, each line length can be unequal, automatically the non-longest string the rightmost fill the space
% makes equal to longest string, ignores empty string
e=strvcat(a,b,m)
Size (E)
% char connection, empty string will be filled with spaces
f=Char(a,b,m)
Size (f)
% strcmp compares whether two strings are exactly equal, yes, returns TRUE, otherwise, returns false
% strncmp compares two strings before n characters are equal, yes, returns TRUE, otherwise, returns false
% strcmPi compares two strings for exact equality, ignoring the case of letters
% Strncmpi compares two strings before n characters are equal, ignoring the case of letters
% Isletter to detect if each character in the string is an English letter
% isspace detects whether each character in the string is a format character (space, carriage return, tab, line break, etc.)
% Isstrprop detects whether each character of a character falls within a specified range
A= ' d sdsdsd 15# ';
B=isletter (a)
C=isspace (a)
% string substitution and lookup
% strrep for string substitution, case-sensitive
% Strrep (STR1,STR2,STR3)
% it replaces all str2 strings in the str1 with STR3.
% strfind(str,patten) Find if there is pattern in Str, return to the occurrence position, no return empty array
% findstr(STR1,STR2) finds str1 and str2 where shorter strings appear in longer strings, no return empty array appears
% strmatch(patten,str) Check if Patten is consistent with the leftmost part of STR
% strtok(Str,char) returns the part and the following part of the string specified by Char in Str.
mm= ' Youqwelcome ';
[Mm1,mm2]=strtok (mm, ' Q ')
% Blanks(n) creates a string consisting of n spaces
% Deblank(str) Trimming trailing spaces of a string
% Strtrim(str) cut the beginning and trailing spaces of a string, tab, carriage return
% Lower(str) converts letters in a string to lowercase
% Upper(str) converts letters in a string to uppercase
% sort(str) sorts a string by the ASCII value of the character
% Num2str Converts a number to a numeric string
% Str2Num Converts a numeric string to a number
% Mat2str converts an array into a string
% Int2str converts a numeric array into an array of characters consisting of an integer number
------------------------------
String comparisons in the cell array:
C=cell (2,1);
C (=cellstr) (' xxx ');
C (2,1) =cellstr (' yyyyyyy ');
strcmp (c{1,1},c{2,1});
------------------------------
isequal Test arrays for equality, which can be used to compare whether the two-character array is the same.
(go) Matlab string processing function