Documentation
Determine if input is character array
tf = ischar(A)
example
tf = ischar(A)returns logical1(true) ifAis a character array and logical0(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'
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)
stris a string array, not a character array, soischarreturns0.
str
ischar
Input array, specified as a scalar, vector, matrix, or multidimensional array.Acan be any data type.
This function fully supports GPU arrays. For more information, seeRun MATLAB Functions on a GPU(Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, seeRun MATLAB Functions with Distributed Arrays(Parallel Computing Toolbox).
cellstr|char|is*|isa|iscellstr|isletter|isnumeric|isspace|isstring|isstrprop|string
cellstr
char
is*
isa
iscellstr
isletter
isnumeric
isspace
isstring
isstrprop
string
A modified version of this example exists on your system. Do you want to open this version instead?
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office
Get trial now