Create an array by accumulating the slices of an array into the positions defined by their subscripts along a specified dimension.
The subscripts are defined by the index vector subs.
The dimension is specified by dim. If not given, it defaults
to the first non-singleton dimension. The length of subs must
be equal to size (vals, dim)
.
The extent of the result matrix in the working dimension will be determined by the subscripts themselves. However, if n is defined it determines this extent.
The default action of accumdim
is to sum the subarrays with the
same subscripts. This behavior can be modified by defining the
func function. This should be a function or function handle
that accepts an array and a dimension, and reduces the array along
this dimension. As a special exception, the built-in min
and
max
functions can be used directly, and accumdim
accounts for the middle empty argument that is used in their calling.
The slices of the returned array that have no subscripts associated with them are set to zero. Defining fillval to some other value allows these values to be defined.
An example of the use of accumdim
is:
accumdim ([1, 2, 1, 2, 1], [ 7, -10, 4; -5, -12, 8; -12, 2, 8; -10, 9, -3; -5, -3, -13]) ⇒ [-10,-11,-1;-15,-3,5]
See also: accumarray.
Package: octave