MATLAB Function Reference |
Syntax
Description
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 quotation within the string is indicated by two quotes.
S = [S1 S2 ...]
concatenates character arrays S1
, S2
, etc. into a new character array, S
.
S = strcat(S1, S2, ...)
concatenates S1
, 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.
S =
char
(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:
strvcat
You can convert between character array and cell array of strings using char
and cellstr
. Most string functions support both types.
ischar
(S)
tells if S
is a string variable. iscellstr
(S)
tells if S
is a cell array of strings.
Examples
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.
See Also
char
, cellstr
, ischar
, iscellstr
, strvcat
, sprintf
, sscanf
, input
strfind | strjust |
© 1994-2005 The MathWorks, Inc.