matlab - How can I sum specific values of a column corresponding to unique values of another column, without using the "accumarray" command? -



matlab - How can I sum specific values of a column corresponding to unique values of another column, without using the "accumarray" command? -

i have matrix in matlab:

a=[1 1; 1 2; 1 3; 2 1; 2 5; 2 7; 3 2; 3 1; 3 4];

if

a1=[1 1 1 2 2 2 3 3 3]; first column

and

a2=[1 2 3 1 5 7 2 1 4]; sec column

of matrix, want repeated values "unique(a1)" of a1 sum corresponding values of a2, this:

a3=[1+2+3 1+5+7 2+1+4]=[6 13 7]

but without using "accumarray" command help please?

my consolidator tool you, offering tolerance.

[a1cons,a2cons] = consolidator(a1',a2',@sum) a1cons = 1 2 3 a2cons = 6 13 7

matlab

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -