Main Content

iscellstr

Determine if input is cell array of character arrays

Description

tf = iscellstr(A) returns logical 1 (true) if A is a cell array of character arrays (or an empty cell array), and logical 0 (false) otherwise. A cell array of character arrays is a cell array where every cell contains a character array.

Note

iscellstr returns a 1 (true) for a cell array containing character arrays of any size. Most text-processing functions and conversion functions require input cell arrays to contain only character row vectors and a cell array containing a character array with more than one row result in an error. Use mustBeText to check that cell arrays contain only character vectors.

example

Examples

collapse all

Create different arrays, and then determine if they are cell arrays of character arrays.

Test a cell array of character vectors.

C1 = {'Smith','Chung','Morales'; ...
      'Sanchez','Peterson','Adams'}
C1 = 2×3 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.

Convert C1 to a string array and test it.

str = string(C1)
str = 2×3 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.

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)
tf = logical
   0

C2 has a cell that does not contain a character array, 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

expand all

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

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced before R2006a