iscellstr - Determine if input is cell array of character vectors - MATLAB (original) (raw)

Main Content

Determine if input is cell array of character vectors

Syntax

Description

tf = iscellstr([A](#bvidcsp-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.

example

Examples

collapse all

Determine If Array Is Cell Array of Character Vectors

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' }

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

Convert C1 to a string array and test it.

str = 2x3 string "Smith" "Chung" "Morales" "Sanchez" "Peterson" "Adams"

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]}

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

Input Arguments

collapse all

A — Input array

scalar | vector | matrix | multidimensional array

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™.

Thread-Based Environment

Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.

Distributed Arrays

Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.

This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).

Version History

Introduced before R2006a