Modify Units, Descriptions, and Table Variable Names
This example shows how to access and modify table properties for variable units, descriptions and
names. You also can edit these property values using the Variables Editor.
Load Sample Data
Load the sample patients data and create a table.
load patients
BloodPressure = [Systolic Diastolic];
T = table(Gender,Age,Height,Weight,Smoker,BloodPressure);
Display the first five rows of the table, T.
T(1:5,:)
ans=5×6 table
Gender
Age
Height
Weight
Smoker
BloodPressure
__________
___
______
______
______
_____________
{'Male' }
38
71
176
true
124
93
{'Male' }
43
69
163
false
109
77
{'Female'}
38
64
131
false
125
83
{'Female'}
40
67
133
false
117
75
{'Female'}
49
64
119
false
122
80
T has 100 rows and 6 variables.
Add Variable Units
Specify units for each variable in the table by modifying the table property, VariableUnits. Specify
the variable units as a cell array of character vectors.
T.Properties.VariableUnits = {'' 'Yrs' 'In' 'Lbs' '' ''};
An individual empty character vector within the cell array indicates that the corresponding variable
does not have units.
Add a Variable Description for a Single Variable
Add a variable description for the variable, BloodPressure. Assign a single character vector to the
element of the cell array containing the description for BloodPressure.
T.Properties.VariableDescriptions{'BloodPressure'} = 'Systolic/Diastolic';
You can use the variable name, 'BloodPressure', or the numeric index of the variable, 6, to index
into the cell array of character vectors containing the variable descriptions.
Summarize the Table
View the data type, description, units, and other descriptive statistics for each variable by using
summary to summarize the table.
summary(T)
9 Tables
9-24
Précédent

- 368/1450

Suivant