Finding Mean of a repeated entries Using Matlab.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Saheed Adio
el 4 de Feb. de 2014
Comentada: Saheed Adio
el 4 de Feb. de 2014
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 comentarios
Respuesta aceptada
Amit
el 4 de Feb. de 2014
b = [u,accumarray(ix,zz(:,1))./accumarray(ix,1)];
The second accumarray will be (ix,1) not (ix,2)
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Graphics Object Properties en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!