Test for categorical array categories
tf = iscategory(A,catnames)
example
tf = iscategory(A,catnames) returns an array containing logical 1 (true) where the data in catnames is a category of A. Otherwise, iscategory returns logical 0 (false).
A
catnames
1
true
iscategory
0
false
tf is the same size as catnames.
tf
collapse all
Create an ordinal categorical array, A.
A = categorical({'shirt' 'pants'; 'pants' 'hat'; 'shirt' 'pants'})
A = 3x2 categorical shirt pants pants hat shirt pants
A is a 3-by-2 categorical array.
Test if the articles of clothing, shirt, pants, socks, and shoes, are categories of A.
shirt
pants
socks
shoes
catnames = {'shirt' 'pants' 'socks' 'shoes'}; tf = iscategory(A,catnames)
tf = 1x4 logical array 1 1 0 0
shirt and pants are categories of A, but socks and shoes are not.
iscategory does not tell us anything about the category, hat, which we did not include in catnames.
hat
Create a categorical array, A.
A = categorical({'plane' 'car' 'train' 'car' 'plane'},... {'boat' 'car' 'plane' 'train'})
A = 1x5 categorical plane car train car plane
A is a 1-by-5 categorical array.
Test to see if boat is a category in A.
boat
tf = iscategory(A,'boat')
tf = logical 1
iscategory returns true, even though A does not contain any values from the category boat.
Categorical array, specified as a vector, matrix, or multidimensional array.
Category names, specified as a character vector, cell array of character vectors, string array, or categorical array.
This function fully supports tall arrays. For more information, see Tall Arrays.
This function fully supports code generation. For more information, see Code Generation for Categorical Arrays (MATLAB Coder).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
addcats | categorical | categories | ismember | mergecats | removecats | renamecats | reordercats | setcats | unique
addcats
categorical
categories
ismember
mergecats
removecats
renamecats
reordercats
setcats
unique
You have a modified version of this example. Do you want to open this example with your edits?