Average values in bins in a matrix with integer values.
1 次查看(过去 30 天)
显示 更早的评论
Hi all,
I have a matrix with two column and want to (elevation and snow depth) and want to use elevation column to make bins (letès say for every 11.5 meter) and average the snowdepth data based on that. a part of My datalooks like attached. ![data.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/203331/data.jpeg)
![data.jpg](https://www.mathworks.com/matlabcentral/answers/uploaded_files/203331/data.jpeg)
Finally I would have a matrix with two clumns, is elevation bins and the other is average snow depth in that range. Please pay attention that the value are not integer and some funcitons that has previously being suggested cannot handle non-integer values. Any idea would be greatly appreciated.
1 个评论
Image Analyst
2019-2-9
Please make it easy for us to help you by attaching your data in a .mat file with the paper clip icon. I would think you could just have a for loop where you mask your data to the range of interest and get the mean, something like
for k = .....
elevation1 = .....
elevation2 = .....
mask = elevation >= elevation1 & elevation < elevation2;
meanDepth(k) = mean(snowDepth(mask));
end
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!