Character array
A character array is a sequence of characters, just as a numeric array is a sequence of numbers. A typical use is to store a short piece of text as a row of characters in a character vector.
You can create a character vector using single quotation marks.
C = 'Hello, world'
C =
'Hello, world'
If you have an array of a different data type, you can convert it to a character array
using the char function, described below.
converts the
arrays C = char(A1,...,An)A1,...,An into a single character array. After
conversion to characters, the input arrays become rows in
C. The char function pads rows
with blank spaces as needed. If any input array is an empty character array,
then the corresponding row in C is a row of blank
spaces.
The input arrays A1,...,An cannot be string arrays,
cell arrays, or categorical arrays.
A1,...,An can be of different sizes and shapes.
Converting a char array to
a numeric type will produce an array of the corresponding Unicode code values. Text in strings does not convert in this way.
Converting a string that does not represent a single numeric value to
double will produce a NaN result. For
more information, see Unicode and ASCII Values.
cellstr | convertCharsToStrings | convertStringsToChars | double | iscellstr | ischar | isstring | string