Finding Mean of a repeated entries Using Matlab.
조회 수: 1 (최근 30일)
이전 댓글 표시
I have repeated entries as shown below in a .csv file. I imported as a matrix or as an array into the matlab environment. What i need to do is to find the mean of the viscosity values at each repeated temperatures and return both the Temperature and the Mean Value of the viscosity in two separate columns.
I have applied this code:
[u,~,ix] = unique(zz(:,2));
b = [u,accumarray(ix,zz(:,1))./accumarray(ix,2)];
It worked ONLY that it returns the half the viscosity values. What is wrong please???
Viscosity Temperature
55.3900000000000 70
55.4900000000000 70
55.4900000000000 70
55.5600000000000 69.9900000000000
55.5600000000000 69.9900000000000
55.4800000000000 69.9800000000000
55.5600000000000 69.9800000000000
55.6100000000000 69.9700000000000
55.6500000000000 69.9700000000000
55.7600000000000 69.9600000000000
55.7800000000000 69.9600000000000
55.7800000000000 69.9500000000000
55.7600000000000 69.9500000000000
55.7000000000000 69.9400000000000
55.6600000000000 69.9300000000000
55.6900000000000 69.9300000000000
VALUES RETURNED AFTER THE CODE WAS RAN:
69.9300 27.8375
69.9400 27.8500
69.9500 27.8850
69.9600 27.8850
69.9700 27.8150
69.9800 27.7600
69.9900 27.7800
70.0000 27.7283
댓글 수: 0
채택된 답변
Amit
2014년 2월 4일
b = [u,accumarray(ix,zz(:,1))./accumarray(ix,1)];
The second accumarray will be (ix,1) not (ix,2)
댓글 수: 3
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!