Access categorical array labels
Syntax
labels = getlabels(A)
Description
labels = getlabels(A) returns
the labels of the levels in the categorical array A as
a cell array of strings labels. For ordinal A,
the labels are returned in the order of the levels.
Examples
Example 1
Display levels in a nominal and an ordinal array:
standings = nominal({'Leafs','Canadiens','Bruins'});
getlabels(standings)
ans =
'Bruins' 'Canadiens' 'Leafs'
standings = ordinal(1:3,{'Leafs','Canadiens','Bruins'});
getlabels(standings)
ans =
'Leafs' 'Canadiens' 'Bruins'Example 2
Display age groups containing data in hospital.mat:
load hospital
edges = 0:10:100;
labels = strcat(num2str((0:10:90)','%d'),{'s'});
AgeGroup = ordinal(hospital.Age,labels,[],edges);
AgeGroup = droplevels(AgeGroup);
getlabels(AgeGroup)
ans =
'20s' '30s' '40s' '50s'See Also
getlevels, setlabels
 | get (dataset) | | getlevels (categorical) |  |
Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
Get the Interactive Kit