This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


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.


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'; ...
C1 = 2x3 cell array
    {'Smith'  }    {'Chung'   }    {'Morales'}
    {'Sanchez'}    {'Peterson'}    {'Adams'  }

tf = iscellstr(C1)
tf = logical

Every cell of C1 contains a character vector, so iscellstr returns 1.

Convert C1 to a string array and test it.

str = string(C1)
str = 2x3 string array
    "Smith"      "Chung"       "Morales"
    "Sanchez"    "Peterson"    "Adams"  

tf = iscellstr(str)
tf = logical

str is a string array, not a cell array, so iscellstr returns 0.

Test a cell array that contains elements of different data types.

X = rand(1,3);
C2 = {'red','blue',X}
C2 = 1x3 cell array
    {'red'}    {'blue'}    {1x3 double}

tf = iscellstr(C2)
tf = logical

C2 has a cell that does not contain a character vector, so iscellstr returns 0.

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. A can be any data type.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a