|MATLAB Function Reference|
MATLAB string handling
S = 'Any Characters' creates a character array, or string. The string is actually a vector whose components are the numeric codes for the characters (the first 127 codes are ASCII). The actual characters displayed depend on the character set encoding for a given font. The length of
S is the number of characters. A quote within the string is indicated by two quotes.
S = [S1 S2 ...] concatenates character arrays
S2, etc. into a new character array,
S2, etc., which can be character arrays or cell arrays of strings. When the inputs are all character arrays, the output is also a character array. When any of the inputs is a cell array of strings,
strcat returns a cell array of strings.
Trailing spaces in
strcat character array inputs are ignored and do not appear in the output. This is not true for
strcat inputs that are cell arrays of strings. Use the
S = [S1 S2 ...] concatenation syntax, shown above, to preserve trailing spaces.
(X) can be used to convert an array that contains positive integers representing numeric codes into a MATLAB character array.
X = double(S) converts the string to its equivalent double precision numeric codes.
A collection of strings can be created in either of the following two ways:
You can convert between character array and cell array of strings using
cellstr. Most string functions support both types.
(S) tells if
S is a string variable.
S) tells if
S is a cell array of strings.
Create a simple string that includes a single quote.
Create the string,
name, using two methods of concatenation.
Create a vertical array of strings.
Create a cell array of strings.