How to average the values in the third column with respect to some interval in first column??

1 visualización (últimos 30 días)
Hi I have a problem in analyzing a matrix. Suppose i have m*3 matrix having values of latitude, longitudes and height, for example say (0.01,0.5,0.8,1.0,2.5,3.6,5.6,40.0,37.5.....n; 88.9,60.5, 60.6, 87.5, 85.3,99.9, 84.6, 89.5, 90.3, 60.5, 61.3 ....n; 455, 481, 452, 355,............n); the latitude and longitudes values are not ascending or descending, these are scattered values.. if i have to average the values in the third column i.e., height for some interval in the first column i.e., latitude 0-2, 2-4, 4-6.....38-40 (0:2:40) how can i do it sir? please help ...thanks again

Respuesta aceptada

Jos (10584)
Jos (10584) el 7 de Abr. de 2014
[~,idx] = histc(LatitudeValues, 0:2:40)
result = accumarray(idx, HeightValues, [], @mean)
  4 comentarios
TRAILOKYA
TRAILOKYA el 15 de Abr. de 2014
Sir, the above code is for averaging the third column with respect to first column...if i have another columns say 3:125; How can I average all the columns with respect to first column similar to above example. I mean Height values have columns 3:125. Should I use the same code as above?
TRAILOKYA
TRAILOKYA el 17 de Abr. de 2014
instead of averaging how can i count the number of height values appearing...should i do in the following way??
[~,idx] = histc(LatitudeValues, 0:2:40) result = accumarray(idx, HeightValues, [], @count)
but not getting the number of values...please help

Iniciar sesión para comentar.

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by