timetable

Methods

Method Reference: timetable.varfun

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

Apply a function to each variable of a timetable.

B = varfun (func, A) applies the function handle func separately to each variable of the timetable A and returns the results in the timetable B. Each variable is passed whole, so a function that reduces a column to a scalar gives a one-row result. The output variables are named for the function and the variable they came from, as in mean_Speed, and every row of the result carries the row time of the first row it was computed from.

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

'InputVariables'
The variables of A that func is applied to, 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 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.
'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