Documentation

iscellstr

Determine if input is cell array of character vectors

Syntax

tf = iscellstr (A)

Description

example

tf = iscellstr (A)returns logical1(true) ifAis a cell array of character vectors (or an empty cell array), and logical0(false) otherwise. A cell array of character vectors is a cell array where every cell contains a character vector.

Examples

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 =2×3 cell array'Smith' 'Chung' 'Morales' 'Sanchez' 'Peterson' 'Adams'
tf = iscellstr (C1)
tf =logical1

Every cell ofC1contains a character vector, soiscellstrreturns1.

ConvertC1to a string array and test it.

str = string(C1)
str =2×3 string array"Smith" "Chung" "Morales" "Sanchez" "Peterson" "Adams"
tf = iscellstr (str)
tf =logical0

stris a string array, not a cell array, soiscellstrreturns0.

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' [1×3 double]
tf = iscellstr (C2)
tf =logical0

C2has a cell that does not contain a character vector, soiscellstrreturns0.

Input Arguments

collapse all

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

Extended Capabilities

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

Introduced before R2006a

Was this topic helpful?