str is a 2-by-3 string array. You can find the lengths of the strings with the strlength
function.
whos str
Name Size Bytes Class Attributes
str 2x3 484 string
L = strlength(str)
L = 2×3
7 6 6
6 8 3
As an alternative, you also can convert a cell array of character vectors to a string array
using the string function.
C = {'Mercury','Venus','Earth'};
str = string(C)
str = 1x3 string array
"Mercury" "Venus" "Earth"
Use string arrays to store and work with multiple pieces of text. You can find and replace
substrings, sort and reshape string arrays, and work with text as data. For more
information on string arrays, see “Create String Arrays” on page 6-12.
See Also
cellstr | char | string | strlength
Related Examples
- “Create Character Arrays” on page 6-6
- “Create String Arrays” on page 6-12
- “Analyze Text Data with String Arrays” on page 6-24
- “Cell Arrays of Character Vectors” on page 6-21
6 Characters and Strings