%% Return Summary of Table as Structure
% Create a table. Add units to the table variables. Then display the first few rows.

load patients
BloodPressure = [Systolic Diastolic];
T = table(Gender,Age,Smoker,BloodPressure,'RowNames',LastName);
T.Properties.VariableUnits =  {''  'Years' ''  'mm Hg'};
head(T,3)

%
% Return a summary of the table. To return a summary as a structure, specify an output argument when using the summary function.

s = summary(T)

%
% Display the summary of the table variable Age. For each variable of T, the output argument s has a field that contains its summary.

s.Age

%
% The NumMissing field shows the number of elements that are the missing value. In this case, Age does not contain any NaN values, so NumMissing is zero. summary includes the NumMissing field for numeric, duration, datetime, and categorical variables.
% Display the minimum age contained in the table. You can access any field of the summary by name.

s.Age.Min

%
% Display the summary of the table variable Smoker. You can determine the numbers of smokers and nonsmokers from the True and False fields. The information contained in the summary of a table variable depends on the data type of the variable.

s.Smoker

% Copyright 2012 The MathWorks, Inc.