addprop

Adds custom properties to a table or timetable.

Category: Language Fundamentals > Data Types

Syntax

T = addprop(T, propNames, propTypes)

Adds one custom property, or several when given cell arrays, to T.

Description

Custom properties carry metadata, such as the source of the data or the unit of each column, that travels with the table. Afterwards, read and write them through T.Properties.CustomProperties. Variable-type properties hold one element per column, usually in a cell array.

Input arguments

T
A table or timetable.
propNames
Property name, or cell array of names.
propTypes
'table' for one value for the whole table, or 'variable' for one entry per variable.

Output arguments

T
The table with the new properties, initially empty.

Example

Attach metadata

T = table([1; 2], 'VariableNames', {'A'});
T = addprop(T, 'Source', 'table');
T.Properties.CustomProperties.Source = 'lab';
disp(T.Properties.CustomProperties.Source)
Output
lab

Notes

addprop also exists for dynamic properties of handle objects (dynamicprops); that use is not available in MatLivre.

See also

table addvars timetable summary