Averaging and locating data points using a 2D grid mesh

15 ビュー (過去 30 日間)
Adam
Adam 2013 年 8 月 20 日
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 Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by