string
Array representing sequences of characters.
A string array is an array, where each element stores a sequence of characters of arbitraty length.
A string array can also have missing elements, which differ from a sequence of characters of zero length (the equivalent of an empty character vector).
To enable existing functions to handle string arrays as if they were cell
arrays of character vectors or character arrays, use the
convertCharsToStrings
function inside your code. To enable
functions working with string arrays to accept cell arrays of character
vectors or character vectors as if they were string arrays or string
scalars, use the convertStringsToChars
function.
See also: convertCharsToStrings, convertStringsToChars
Source Code: string
'Format'
, FMT)'Format'
, FMT)Create a new string array.
str = string ()
creates a scalar string array, whose element
contains an empty character vector.
str = string (in)
creates a string array of the same
size as in, which is converted to string according to the following
options:
cellstr
function.
num2str
function.
false
or
true
character sequences.
cellstr
method.
dispstrings
method.
cellstr
methods, in which case an extra pair argument
is supported to allow parsing to the respective method the appropriate
display format. See calendarDuration
and duration
for
valid formats parsed through FMT to each class method. Extra input
arguments to the string
constructor except for this case are
ignored.
str = string ({in1, …, inN})
creates a
string array from a cell array, which may contain any combination of the
aforementioned data types, provided that each cell element is compatible
to a string scalar. When using this syntax, calendarDuration arrays and
duration arrays are converted via their dispstrings
method, hence
no extra format argument is meaningful.
See also: calendarDuration, categorical, datetime, duration, missing
Convert string array to a cell array of character vectors.
cstr = cellstr (str)
returns a cell array of
character vectors, cstr, which has the same size as the input
string str. Both empty strings and missing values are returned as
empty character vectors.
Convert string array to a cell array.
c_arr = cell (str)
returns a cell array, c_arr,
which has the same size as the input string str. All strings are
converted to character vectors. Empty strings are converted to
''
empty character vectors, while missing values are returned as
[]
empty numeric vectors.
Convert string array to a character matrix.
c_mat = char (str)
returns a character matrix,
c_mat, which contains as many rows as the elements of the string.
Both empty strings and missing values are returned as empty character
vectors.
Convert string array to a double array.
X = char (str)
returns a double array, X, which
has the same size as the input string str. All elements in
str that represent real or complex numbers are converted to
equivalent double values. Otherwise, NaN
is returned.
Return the size of a string array.
sz = size (str)
returns a row vector with the size
(number of elements) of each dimension for the string array str.
dim_sz = size (str, dim)
returns the size of
the corresponding dimension specified in dim. If dim is a
vector, then dim_sz is a vector of the same length and with each
element corresponding to a specified dimension. Multiple dimensions may
also be specified as separate arguments.
With a single output argument, size
returns a row vector. When
called with multiple output arguments, size
returns the size of
dimension N in the Nth argument.
Number of dimensions in a string array.
out = ndims (str)
returns the number of dimensions of
the string array D.
Total number of elements in a string array.
Length of text in string arrays.
Test if string array is a column vector.
TF is true
, if string array str is a column vector.
Test if string array is empty.
TF is true
, if string array str is empty.
Test if string array is a matrix.
TF is true
, if string array str is a matrix.
Test for set member in string arrays.
TF is a logical array of the same size as str1.
Test for missing elements in string array.
TF is a logical array of the same size as str.
Test if string array is a row vector.
TF is true
, if string array str is a row vector.
Test if string array is a scalar.
TF is true
, if string array str is a scalar.
Test if string array is a vector.
TF is true
, if string array str is a vector.
string.eq
is not documented.
string.ge
is not documented.
string.gt
is not documented.
string.le
is not documented.
string.lt
is not documented.
string.ne
is not documented.
string.append
is not documented.
string.compose
is not documented.
Remove content from string array.
newstr = erase (str, pat)
removes the
occurences of pat from each element of the string array str.
newstr is a string array of the same size as str.
string.eraseBetween
is not documented.
string.extract
is not documented.
string.extractAfter
is not documented.
string.extractBefore
is not documented.
string.extractBetween
is not documented.
string.insertAfter
is not documented.
string.insertBefore
is not documented.
string.replace
is not documented.
string.replaceBetween
is not documented.
Reverse order of characters in string array.
newstr = reverse (str)
reverses the order of the
characters in every each element of the string array str.
newstr is a string array of the same size as str.
string.sort
is not documented.
string.split
is not documented.
Horizontal concatenation of texts in string array.
newstr = strcat (str1, str2, …)
merges
horizontally all the input arguments into a string array, as long as any
of the input arguments is a string array. All inputs must be of common
size or scalars. All inputs must be character vectors, cell arrays of
character vectors, or string arrays.
string.strip
is not documented.
string.pad
is not documented.
string.join
is not documented.
string.plus
is not documented.
Convert contents of strinf array to lower case.
newstr = lower (str)
converts all upper case
characters in every element of the string array str to lower case.
newstr is a string array of the same size as str.
Convert contents of strinf array to upper case.
newstr = upper (str)
converts all lower case
characters in every element of the string array str to upper case.
newstr is a string array of the same size as str.