FUNCTION REFERENCE

splitapply

Apply a function to each group of data.

Apply a function to each group of data.

Syntax

Y = splitapply(func, X1, ..., Xn, G)

Syntax

[Y1, ..., Ym] = splitapply(...)

G holds group numbers 1..N (NaN rows are skipped). func gets the rows of each X in a group (a table gives its variables as separate inputs); the results of the groups are stacked vertically.

Example

splitapply(@mean, [10;20;30], [1;2;1])   % [20; 20]

Differences from MATLAB: Results that are not scalar are stacked vertically instead of being an error.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.