ans=5×6 table
Gender Smoker Height Weight ID BMI
________ ______ ______ ______ ____ ______
Smith 'Male' true 71 176 8148 24.547
Johnson 'Male' false 69 163 9058 24.071
Williams 'Female' false 64 131 1270 22.486
Jones 'Female' false 67 133 9134 20.831
Brown 'Female' false 64 119 6324 20.426
Populate the variable units and variable descriptions properties for BMI. You can add
metadata to any table variable to describe further the data contained in the variable.
T.Properties.VariableUnits{'BMI'} = 'kg/m^2';
T.Properties.VariableDescriptions{'BMI'} = 'Body Mass Index';
Create a histogram to explore whether there is a relationship between smoking and body-
mass-index in this group of patients. You can index into BMI with the logical values from
the Smoker table variable, because each row contains BMI and Smoker values for the
same patient.
tf = (T.Smoker == false);
h1 = histogram(T.BMI(tf),'BinMethod','integers');
hold on
tf = (T.Smoker == true);
h2 = histogram(T.BMI(tf),'BinMethod','integers');
xlabel('BMI (kg/m^2)');
ylabel('Number of Patients');
legend('Nonsmokers','Smokers');
title('BMI Distributions for Smokers and Nonsmokers');
hold off
9 Tables