how to count the number of element in observation and make summation?

3 views (last 30 days)
c b a 110
a d a 1551
a b b 502
a b c 179
d b a 124
For the observations given above, I want to count the number of elements in individual observations
and want to divide the value of the 4th column proportionally, according to the number of element in the same row.
For example, for above example, I want to give a=110/3+ 1551*2/3+502/3+179/3+124/3.
Does anyone know how to compute this in matlab?
For your reference, I will attach my .mat file.
Thank you.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 18 Apr 2019
K = B.TotalRevenue.*ones(size(B,1),3)/3;
[a1,~,c1] = unique(B{:,1:3});
out = table(a1,accumarray(c1,K(:)),'v',{'opals','Revenue'});

More Answers (0)

Categories

Find more on Automotive in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!