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)
更多回答(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!