Consider the sample table from above. Each row in the table, T, represents a different
patient. The workspace variable, LastName, contains unique identifiers for the 100 rows.
Add row names to the table by setting the RowNames property to LastName and display
the first five rows of the updated table.
T.Properties.RowNames = LastName;
T(1:5,:)
ans=5×4 table
Gender Age Smoker BloodPressure
Smith Male 38 true 124 93
Johnson Male 43 false 109 77
Williams Female 38 false 125 83
Jones Female 40 false 117 75
Brown Female 49 false 122 80
In addition to labeling the data, you can use row and variable names to access data in the
table. For example, use named indexing to display the age and blood pressure of the
patients Williams and Brown.
T({'Williams','Brown'},{'Age','BloodPressure'})
ans=2×2 table
Age BloodPressure
Williams 38 125 83
Brown 49 122 80
Now, use numeric indexing to return an equivalent subtable. Return the third and fifth
row from the second and fourth variables.
T(3:2:5,2:2:4)
ans=2×2 table
Age BloodPressure
Williams 38 125 83
Brown 49 122 80
Advantages of Using Tables