I need to understand accumarray to write a code that I really need.
I tried to understand http://www.mathworks.co.kr/kr/help/matlab/ref/accumarray.html
Most examples were clear.
However, in the 1st example of Example 2, I thought
(1,2)th element of B should be 1
because
(1,2) = 1st, 2nd of subs
1st, 2nd of vals = 101, 102
sum(diff([101,102]))=1
Also, in the 2nd example of Example 2, I thought
(1,2)th element of B1 should be 2 instead of -2
because
(1,2) = 1st, 3rd of subs
1st, 3rd of vals = 101, 103
sum(diff([101,103]))=2
and also I thought
(4,1)th element of B1 should be 1 instead of -1
because
(4,1) = 5,6th of subs
5,6th of vals = 105,106
sum(diff([105,106]))=1
What am I missing?
Please correct, I need to understand accumarray in depth to write my own code.