| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Statistics Toolbox |
| Contents | Index |
| Learn more about Statistics Toolbox |
Summary statistics for categorical array
summary(A)
C = summary(A)
[C,labels] = summary(A)
summary(A) displays the number of elements in the categorical array A equal to each of the possible levels in A. If A contains any undefined elements, the output also includes the number of undefined elements.
C = summary(A) returns counts of the number of elements in the categorical array A equal to each of the possible levels in A. If A is a matrix or N-dimensional array, C is a matrix or array with rows corresponding to the levels of A. If A contains any undefined elements, C contains one more row than the number of levels of A, with the number of undefined elements in c(end) or c(end,:).
[C,labels] = summary(A) also returns the list of categorical level labels corresponding to the counts in C.
Count the number of patients in each age group in the data in hospital.mat:
load hospital
edges = 0:10:100;
labels = strcat(num2str((0:10:90)','%d'),{'s'});
AgeGroup = ordinal(hospital.Age,labels,[],edges);
[c,labels] = summary(AgeGroup);
Table = dataset({labels,'AgeGroup'},{c,'Count'});
Table(3:6,:)
ans =
AgeGroup Count
'20s' 15
'30s' 41
'40s' 42
'50s' 2islevel, ismember, levelcounts
![]() | subsref (qrandset) | summary (dataset) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |