Jones
40
{'Female'}
67
133
false
Brown
49
{'Female'}
64
119
false
Davis
46
{'Female'}
68
142
false
Miller
33
{'Female'}
64
142
true
Wilson
40
{'Male' }
68
180
false
Moore
28
{'Male' }
68
183
false
Taylor
31
{'Female'}
66
132
false
Anderson
45
{'Female'}
68
128
false
Thomas
42
{'Female'}
66
137
false
Jackson
25
{'Male' }
71
174
false
White
39
{'Male' }
72
202
true
Harris
36
{'Female'}
65
129
false
Martin
48
{'Male' }
71
181
true
⋮
Index Using Numeric Indices
Create a subtable containing the first five rows and all the variables from T. To specify the desired
rows and variables, use numeric indices within parentheses. This type of indexing is similar to
indexing into numeric arrays.
T1 = T(1:5,:)
T1=5×5 table
Age
Gender
Height
Weight
Smoker
___
__________
______
______
______
Smith
38
{'Male' }
71
176
true
Johnson
43
{'Male' }
69
163
false
Williams
38
{'Female'}
64
131
false
Jones
40
{'Female'}
67
133
false
Brown
49
{'Female'}
64
119
false
T1 is a 5-by-5 table.
In addition to numeric indices, you can use row or variable names inside the parentheses. (In this
case, using row indices and a colon is more compact than using row or variable names.)
Index Using Names
Select all the data for the patients with the last names 'Williams' and 'Brown'. Since T has row
names that are the last names of patients, index into T using row names.
T2 = T({'Williams','Brown'},:)
T2=2×5 table
Age
Gender
Height
Weight
Smoker
___
__________
______
______
______
Williams
38
{'Female'}
64
131
false
Brown
49
{'Female'}
64
119
false
T2 is a 2-by-5 table.
You also can select variables by name. Create a table that has only the first five rows of T and the
Height and Weight variables. Display it.
9 Tables
9-36
Précédent

- 380/1450

Suivant