- #1
atrus_ovis
- 101
- 0
accumarray documentation
Is anyone proficient in the use of accumarray?
I supply two vectors of same length, indices L,weights W, L positive integers as required.
I sort the indices to ascending.Then, the result of accumarray is not equal to unique(L).How could this be?
Code for illustration:
I get 49 weight vectors for the 9 indices, the unique of which are 4!
Is anyone proficient in the use of accumarray?
I supply two vectors of same length, indices L,weights W, L positive integers as required.
I sort the indices to ascending.Then, the result of accumarray is not equal to unique(L).How could this be?
Code for illustration:
Code:
i = [46 47 47 46 48 49 48 48 48]';
w = 2*rand(size(i));
Y=[i';w'];
[x y] = sort(Y(1,:));
Y = Y(:,y);
Y,pause
uw = accumarray((Y(1,:))',Y(2,:)');
ui = unique(i);
numel(uw),numel(ui)
--- OUTPUT :
Y =
46.0000 46.0000 47.0000 47.0000 48.0000 48.0000 48.0000 48.0000 49.0000
1.5844 0.0714 1.9190 1.3115 1.6983 1.3575 1.5155 1.4863 1.8680ans =
49ans =
4