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

采纳的回答

Amit
Amit 2014-2-4
b = [u,accumarray(ix,zz(:,1))./accumarray(ix,1)];
The second accumarray will be (ix,1) not (ix,2)
  3 个评论
Saheed Adio
Saheed Adio 2014-2-4
Hi Amit, please i do not want the code to round up the figures and I also do not want it in scientific mode (i.e. not in this form) b =
1.0e+03 *
0 0.0000
0.0200 1.3528
0.0200 1.3520
0.0200 1.3515
0.0200 1.3496
0.0200 1.3471
0.0201 1.3466
0.0201 1.3462
0.0201 1.3448
I want it as shown below:
0 0.0000
20.0000 676.4167
20.0100 676.0175
20.0200 675.7475
20.0300 674.8250
20.0400 673.5425
20.0500 673.3150
20.0600 673.1033
20.0700 672.4050
20.0800 672.1225
20.0900 671.6117
20.1000 670.8650
20.1100 670.1250
20.1200 669.5333
20.1300 669.1275
20.1400 668.2750
20.1500 667.1333
20.1600 666.6725
20.1700 666.3575
20.1800 665.6383
20.1900 665.2925
20.2000 665.1675
20.2100 664.9033
20.2200 663.8675
BOTTOM LINE: How can I change this display format. I don't want the scientific notation stuff.
Thanks.
Saheed Adio
Saheed Adio 2014-2-4
Hi Amit,
I used format short g and it worked. Thanks!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by