cellstr
Converts text to a cell array of character vectors.
Category: Language Fundamentals > Data Types
Syntax
c = cellstr(A)
Converts a char matrix, string array or categorical array.
Description
Many functions that accept a list of names expect a cell array of character vectors, and cellstr is the standard way to produce one. For a char matrix the padding blanks that make the rows equal in length are dropped, which makes it the inverse of char for lists of words.
A single string becomes a 1-by-1 cell. An empty char '' becomes a cell holding an empty char.
Input arguments
A- Char array, string array, categorical array, or a cell array of text.
Output arguments
c- Cell array of character vectors. A char matrix gives one cell per row, with trailing blanks removed.
Example
Rows of a char matrix
cellstr(['ab ';'cde'])
cellstr(["a" "bc"])
Output
ans = 2×1 cell
{'ab' }
{'cde'}
ans = 1×2 cell
{'a'} {'bc'}