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

1 回表示 (過去 30 日間)
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

採用された回答

Jos (10584)
Jos (10584) 2014 年 4 月 7 日
[~,idx] = histc(LatitudeValues, 0:2:40)
result = accumarray(idx, HeightValues, [], @mean)
  4 件のコメント
TRAILOKYA
TRAILOKYA 2014 年 4 月 15 日
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 2014 年 4 月 17 日
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

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by