Documentation

ischar

Determine if input is character array

Description

example

tf = ischar(A)returns logical1(true) ifAis a character array and logical0(false) otherwise.

Examples

collapse all

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

Test a character vector.

chr ='Mary Jones'
chr = 'Mary Jones'
tf = ischar(chr)
tf =logical1

Test a numeric array.

X = rand(1,3)
X =1×30.8147 0.9058 0.1270
tf = ischar(X)
tf =logical0

Test a string array. Starting in R2017a, you can create strings using double quotes.

str = ["Smith","Chung","Morales";..."Sanchez","Peterson","Adams"]
str =2x3 string array"Smith" "Chung" "Morales" "Sanchez" "Peterson" "Adams"
tf = ischar(str)
tf =logical0

stris a string array, not a character array, soischarreturns0.

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