MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
Starting in R2016b, you can assign new names to the dimension names, and use them to
access table data. Dimension names must be valid MATLAB identifiers, and must not be
one of the reserved names, 'Properties', 'RowNames', or 'VariableNames'.

Assign a new name to the first dimension name, and use it to access the row names of the
table.

T.Properties.DimensionNames{1} = 'Name';
T.Name

ans =

5×1 cell array

'Van Buren'
'Arthur'
'Fillmore'
'Garfield'
'Polk'

Create a new table variable called Name. When you create the variable, the table modifies
its first dimension name to prevent a conflict. The updated dimension name becomes
Name_1.

T{:,'Name'} = {'Martin'; 'Chester'; 'Millard'; 'James'; 'James'}

Warning: DimensionNames property was modified to avoid conflicting dimension and variable names:
'Name'. See Compatibility Considerations for Using Tables for more details. This will become an
error in a future release.
T =
Number Party Name
______ __________ _________
Van Buren 8 Democratic 'Martin'
Arthur 21 Republican 'Chester'
Fillmore 13 Whig 'Millard'
Garfield 20 Republican 'James'
Polk 11 Republican 'James'

T.Properties.DimensionNames

ans =

1×2 cell array

'Name_1' 'Data'

9 Tables

Free download pdf