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