필터 지우기
필터 지우기

Averaging and locating data points using a 2D grid mesh

조회 수: 14 (최근 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 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