Perry 'Female' 64 120
Alexander 'Male' 69 171
T3 is a 15-by-3 table.
Create Array from the Contents of Table
This example shows how to extract the contents of a table using curly braces or dot
indexing.
Load Sample Data
Load the sample patients data and create a table. Use the unique identifiers in LastName
as row names.
load patients
patients = table(Age,Gender,Height,Weight,Smoker,...
'RowNames',LastName);
The table, patients, contains 100 rows and 5 variables.
Extract Multiple Rows and Multiple Variables
Extract data from multiple variables in the table, patients by using curly braces. Since
dot indexing extracts data from a single variable at a time, braces are more convenient
when you want to extract more than one variable.
Extract the height and weight for the first five patients. Use numeric indices to select the
subset of rows, 1:5, and variable names to select the subset of variables,
{Height,Weight}.
A = patients{1:5,{'Height','Weight'}}
A = 5×2
71 176
69 163
64 131
67 133
64 119
Access Data in a Table