A = accumarray(subs, val)
A = accumarray(subs, val, sz)
A = accumarray(subs, val, sz, fun)
A = accumarray(subs, val, sz, fun, fillval)
| Parameter | Description |
|---|---|
| subs | subscripts: column vector or matrix of positive integers. |
| val | values to accumulate: column vector or scalar. |
| sz | size of the output: row vector or []. |
| fun | accumulation function: function handle (default @sum). |
| fillval | value for empty positions (default 0). |
| Parameter | Description |
|---|---|
| A | accumulated array. |
accumarray(subs, val) groups the elements of val by the subscripts in subs and applies @sum to each group.
Each row of subs is the position in the output where the corresponding value of val is accumulated.
fun replaces the default sum, and fillval sets the value of positions that receive no contribution.
accumarray([1;2;1;3], [10;20;30;40])
accumarray([1;1;2], [3;5;7], [], @max)
| Version | Description |
|---|---|
| 2.0.0 | initial version |