Help Center
Determine if input is cell array of character vectors
tf = iscellstr(A)
tf = iscellstr(A) returns logical 1 (true) if A is a cell array of character vectors (or an empty cell array), and logical 0 (false) otherwise. A cell array of character vectors is a cell array where every cell contains a character vector.
A
1
true
0
false
example
collapse all
Create different arrays, and then determine if they are cell arrays of character vectors.
Test a cell array of character vectors.
C1 = {'Smith','Chung','Morales'; ... 'Sanchez','Peterson','Adams'}
C1 = 2x3 cell {'Smith' } {'Chung' } {'Morales'} {'Sanchez'} {'Peterson'} {'Adams' }
tf = iscellstr(C1)
tf = logical 1
Every cell of C1 contains a character vector, so iscellstr returns 1.
C1
iscellstr
Convert C1 to a string array and test it.
str = string(C1)
str = 2x3 string "Smith" "Chung" "Morales" "Sanchez" "Peterson" "Adams"
tf = iscellstr(str)
tf = logical 0
str is a string array, not a cell array, so iscellstr returns 0.
str
Test a cell array that contains elements of different data types.
X = rand(1,3); C2 = {'red','blue',X}
C2=1×3 cell array {'red'} {'blue'} {[0.8147 0.9058 0.1270]}
tf = iscellstr(C2)
C2 has a cell that does not contain a character vector, so iscellstr returns 0.
C2
Input array, specified as a scalar, vector, matrix, or multidimensional array. A can be any data type.
backgroundPool
ThreadPool
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Introduced before R2006a
cellstr | char | iscell | isstrprop | isstring | ischar | string
cellstr
char
iscell
isstrprop
isstring
ischar
string
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other bat365 country sites are not optimized for visits from your location.
Americas
Europe
Asia Pacific
Contact your local office