FUNCTION REFERENCE
accumarray
Group values by subscripts and combine each group.
Group values by subscripts and combine each group.
Syntax
A = accumarray(subs, val)Syntax
A = accumarray(subs, val, sz)Syntax
A = accumarray(subs, val, sz, fun)Syntax
A = accumarray(subs, val, sz, fun, fillval)subs is a column of positive integers or an N-by-D matrix of subscripts;
val is one value per row of subs, or a scalar. fun combines each group: 'sum' (default),
'max', 'min' or 'prod'. Positions with no value get fillval (0 by default).
max and min ignore NaN. sz may be [] to use max(subs); for a column subs it must be [n 1].
Example
accumarray([1;2;4;2;4], [101;102;103;104;105]) % [101; 206; 0; 208]fun also accepts function handles.
Differences from MATLAB: no N-D cell output, no cell subs; sparse output has at most two dimensions.
These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.