When using MATLAB accumarray, if the subscripts in `'subs'` are not sorted, the accumulating function ‘`fun`‘ should not depend on the order of the values in its input data. Otherwise you would have weird results. To show the input data for the accumulating function, one can define the function as ‘@(x){x}’. This would save the input data for you. For example,

>> val = 101:105;

>> subs = [1; 2; 4; 2; 4]

>> A = accumarray(subs, val, [], @(x){x})

A =

[ 101]

[2x1 double]

[]

[2x1 double]

### Like this:

Like Loading...

*Related*

BessieYour style is so unique compared to other people I have read

stuff from. Thank you for posting when you’ve got the opportunity, Guess I’ll just bookmark

this web site.