T2=2×5 table
Age Gender Height Weight Smoker
___ ________ ______ ______ ______
Adams 48 'Female' 66 137 false
Brown 49 'Female' 64 119 false
T2 is a 2-by-5 table.
Index Using a Logical Expression
Create a new table, T3, containing the gender, height, and weight of the patients under
the age of 30. Select only the rows where the value in the variable, Age, is less than 30.
Use dot notation to extract data from a table variable and a logical expression to define
the subset of rows based on that extracted data.
rows = patients.Age<30;
vars = {'Gender','Height','Weight'};
rows is a 100-by-1 logical array containing logical true ( 1 ) for rows where the value in
the variable, Age, is less than 30.
Use parentheses to return a table containing the desired subset of the data.
T3 = patients(rows,vars)
T3=15×3 table
Gender Height Weight
________ ______ ______
Moore 'Male' 68 183
Jackson 'Male' 71 174
Garcia 'Female' 69 131
Walker 'Female' 65 123
Hall 'Male' 70 189
Young 'Female' 63 114
Hill 'Female' 64 138
Rivera 'Female' 63 130
Cooper 'Female' 65 127
Cox 'Female' 66 111
Howard 'Female' 68 134
James 'Male' 66 186
Jenkins 'Male' 69 189
9 Tables