MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

A = addcats(A,'xsmall','Before','small');


categories(A)


ans = 5x1 cell array
{'xsmall'}
{'small' }
{'medium'}
{'large' }
{'xlarge'}


Add the categories {'medium','large','xlarge'} to B after the category 'small'.


B = addcats(B,{'medium','large','xlarge'},'After','small');


categories(B)


ans = 5x1 cell array
{'xsmall'}
{'small' }
{'medium'}
{'large' }
{'xlarge'}


The categories of A and B are now the same including their order.


Vertically concatenate A and B.


C = [A;B]


C = 15x1 categorical array
medium
xlarge
small
small
medium
large
medium
large
medium
small
small
xsmall


Work with Protected Categorical Arrays
Free download pdf