splitapply
datatypes: Y = splitapply (func, X, G)
datatypes: Y = splitapply (func, X1, …, XN, G)
datatypes: [Y1, …, YM] = splitapply (…)
Split data into groups and apply a function to each group.
Y = splitapply (func, X, G) splits the data
variable X into groups according to the group numbers G
(typically produced by findgroups), applies the function handle
func to each group, and concatenates the per-group results into the
output Y. G must be a vector of positive integers with one
element per element of X; if it identifies N groups, every
integer between 1 and N must occur at least once. Elements for which
G is NaN are omitted.
Y = splitapply (func, X1, …, XN, G)
splits each of the data variables X1, …, XN and passes the
corresponding group of each as a separate input argument to func.
[Y1, …, YM] = splitapply (…) returns the
multiple outputs of func, each concatenated across groups.
To split the variables of a table, call
splitapply (func, T, G), which dispatches to the
table method.
See also: findgroups, table
Source Code: splitapply