timetable

Methods

Method Reference: timetable.rowfun

timetable: B = rowfun (func, A)
timetable: B = rowfun (func, A, Name, Value, …)

Apply a function to each row of a timetable.

B = rowfun (func, A) applies the function handle func to each row of the timetable A and returns the results in the timetable B, which has one row for each row of A and carries its row times. By default the value of each variable in the row is passed to func as a separate input argument, and the output variables of B are named Var1, Var2, and so on.

B = rowfun (func, A, Name, Value, …) modifies the operation through the following Name/Value pairs:

'InputVariables'
The variables of A that are passed to func, given as variable names, indices, a logical vector, or a function handle. By default every variable of A that is not a grouping variable is used.
'GroupingVariables'
One or more variables of A that define groups of rows, or the row dimension name, which groups by the row times themselves. func is then applied once to each group, receiving the values of each input variable across the rows of the group, and B has one row per group, carrying the row time of the first row of the group. Grouping variables appear in B alongside a GroupCount variable; the row times do not, being the row times of the result. Rows with a missing value in any grouping variable are omitted.
'OutputVariableNames'
The names of the output variables of B, one per output of func.
'NumOutputs'
The number of output arguments to request from func. It defaults to the number of 'OutputVariableNames' if those are given, otherwise to 1.
'SeparateInputs'
A logical scalar. When true (the default), the value of each input variable is passed to func as a separate argument. When false, the values of the row are horizontally concatenated and passed as a single argument.
'ExtractCellContents'
A logical scalar. When true, the contents of cell-valued variables are extracted before being passed to func. It defaults to false.
'OutputFormat'
One of 'table' (the default, and also selected by 'auto'), which returns the results in a timetable; 'uniform', which requires func to return a scalar and returns them in an array; or 'cell', which returns them in a cell array.
'ErrorHandler'
A function handle called whenever func raises an error, receiving a structure with fields identifier, message and index, followed by the arguments func was called with. Its outputs are used in place of the ones func did not return.

Source Code: timetable