Determine if input is character array
tf = ischar(A)
example
tf = ischar(A) returns logical 1 (true) if A is a character array and logical 0 (false) otherwise.
A
1
true
0
false
collapse all
Create different arrays, and then determine if they are character arrays.
Test a character vector.
chr = 'Mary Jones'
tf = ischar(chr)
tf = logical 1
Test a numeric array.
X = rand(1,3)
X = 1×3 0.8147 0.9058 0.1270
tf = ischar(X)
tf = logical 0
Test a string array. Starting in R2017a, you can create strings using double quotes.
str = ["Smith","Chung","Morales"; ... "Sanchez","Peterson","Adams"]
str = 2x3 string "Smith" "Chung" "Morales" "Sanchez" "Peterson" "Adams"
tf = ischar(str)
str is a string array, not a character array, so ischar returns 0.
str
ischar
Input array, specified as a scalar, vector, matrix, or multidimensional array. A can be any data type.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
cellstr | char | iscellstr | isletter | isnumeric | isspace | isstring | isstrprop | string
cellstr
char
iscellstr
isletter
isnumeric
isspace
isstring
isstrprop
string
You have a modified version of this example. Do you want to open this example with your edits?