MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Peterson 32 60 136
Ramirez 48 64 137
Bennett 35 64 131 ⋮

A is a 19-by-3 table.

Since ordinal categorical arrays have a mathematical ordering for their categories, you
can perform element-wise comparisons of them with relational operations, such as
greater than and less than.

Create a subtable, T2, of the gender, age, height, and weight of all patients who assessed
their health status as poor or fair.

First, define the subset of rows to include in table T2.

rows = T.SelfAssessedHealthStatus<='Fair';

Then, define the subset of variables to include in table T2.

vars = {'Gender','Age','Height','Weight'};

Use parentheses to create the subtable T2.

T2 = T(rows,vars)

T2=26×4 table
Gender Age Height Weight
______ ___ ______ ______
Johnson Male 43 69 163
Jones Female 40 67 133
Thomas Female 42 66 137
Jackson Male 25 71 174
Garcia Female 27 69 131
Rodriguez Female 39 64 117
Lewis Female 41 62 137
Lee Female 44 66 146
Hall Male 25 70 189
Hernandez Male 36 68 166
Lopez Female 40 66 137
Gonzalez Female 35 66 118
Mitchell Male 39 71 164
Campbell Female 37 65 135
Parker Male 30 68 182

8 Categorical Arrays

Free download pdf