how to count the number of element in observation and make summation?
조회 수: 3 (최근 30일)
이전 댓글 표시
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.
댓글 수: 0
채택된 답변
Andrei Bobrov
2019년 4월 18일
K = B.TotalRevenue.*ones(size(B,1),3)/3;
[a1,~,c1] = unique(B{:,1:3});
out = table(a1,accumarray(c1,K(:)),'v',{'opals','Revenue'});
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!