Averaging and locating data points using a 2D grid mesh

14 次查看(过去 30 天)
I have a file with the data: x-coordinate, y-coordinate, and f(x,y). For example: 2.33124, 5.90821, 453.009374 .
I would like to use a 2-d square grid with a mesh of, say 50 x 50 boxes to find the average of the f(x,y) values that lie within each box of the grid. I need to then store the average of each box with the box's coordinates on the grid i.e., (1,1),(1,2),(1,3)...(2,1),(2,2)...into the elements of a 2d array.
Are there any functions in matlab which can be used to do this? How can I use Matlab to find out which (x,y) pairs are within which boxes of the grid? What I want to do is simple, but I'm just not sure where to begin.
Thanks!
Adam

回答(1 个)

Image Analyst
Image Analyst 2013-8-20
You can use TriScatteredInterp(), or griddedInterpolant() to make a solid 2D matrix. Then just use mean2 to get the mean in any particular block
thisMean = mean2(solidArray(row1:row2, col1:col2));

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by