For example, if
A = [7,8,1,1,2,2,2]; % the bins (or subscripts)
B = [2,1,1,1,1,1,2]; % the array
then the desired function “binum” has two outputs, one is the bunkers, and the other is the sum. He simply adds the values to B according to the indices in A. For example, for 2 the sum is 1 + 1 + 2 = 4, for 1 it is 1 + 1 = 2.
[bins, sums] = binsum(A,B);
bins = [1,2,7,8]
sums = [2,4,2,1]
Elements in “silos” do not have to be ordered, but must correspond to elements in “sums”. This, of course, can be done using "for" iterations, but "for" iterations are not required because there is a performance issue. Best if there is a build function for this.
Thank you so much!