Test for levels
Syntax
I = islevel(levels,A)
Description
I = islevel(levels,A) returns
a logical array I the same size as the string,
cell array of strings, or 2-D character matrix levels. I is true (1)
where the corresponding element of levels is the
label of a level in the categorical array A, even
if the level contains no elements. I is false (0)
otherwise.
Examples
Display age levels in the data in hospitl.mat,
before and after dropping occupied levels:
load hospital
edges = 0:10:100;
labels = strcat(num2str((0:10:90)','%d'),{'s'});
disp(labels')
'0s' '10s' '20s' '30s' '40s' '50s' '60s' '70s' '80s' '90s'
AgeGroup = ordinal(hospital.Age,labels,[],edges);
I = islevel(labels,AgeGroup);
disp(I')
1 1 1 1 1 1 1 1 1 1
AgeGroup = droplevels(AgeGroup);
I = islevel(labels,AgeGroup);
disp(I')
0 0 1 1 1 1 0 0 0 0See Also
ismember, isundefined
 | isequal (categorical) | | ismember (ordinal) |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit