I just read the documentation of accumarray and can't manage to understand the second example. The example is the following
val = 101:106';
subs = [1 1; 2 2; 3 2; 1 1; 2 2; 4 1]
subs =
1 1
2 2
3 2
1 1
2 2
4 1
A = accumarray(subs,val)
A =
205 0
0 207
0 103
106 0
If I do
B=accumarray(subs(:,1),val)
C=accumarray(subs(:,2),val)
then I get
B=
205
207
103
106
C =
311
310
which is logical to me. But why are the numbers of B
just arranged in "random" (I guess it's not random, but seems random to me) positions of a 4x2
matrix when I add a 2nd column to subs
?