Data picking from grid

10 ビュー (過去 30 日間)
aa
aa 2020 年 9 月 11 日
コメント済み: aa 2020 年 9 月 12 日
I have data in three column (x,y,z)
I want to pick the values of z in each grid ...
For exmaple, in fiure, the values of x are plotted coressponding to x,y. Then with a diffrenec of 1 we grided the plot.
I want to calculate the data points placed in each grid.

採用された回答

KSSV
KSSV 2020 年 9 月 11 日
編集済み: KSSV 2020 年 9 月 12 日
I have edited the code for your given points so that you can get the points for each grid.
x = -130.7:0.1:-129.7 ;
y = 45.6:0.1:46.3 ;
n = length(x) ;
m = length(y) ;
[X,Y] = meshgrid(x,y) ;
data = importdata("data.txt") ;
x = data(:,1) ; y = data(:,2) ; z = data(:,3) ;
% plot grid
plot(X,Y,'r',X',Y','r')
hold on
for i = 1:m-1
for j = 1:n-1
% Get the points of each grid
P = [X(i,j) Y(i,j) ;
X(i,j+1) Y(i,j+1) ;
X(i+1,j+1) Y(i+1,j+1) ;
X(i+1,j) Y(i+1,j)] ;
idx = inpolygon(x,y,P(:,1),P(:,2)) ;
iwant = [x(idx) y(idx) z(idx)] ;
plot(x(idx),y(idx),'.')
drawnow
end
end
  11 件のコメント
KSSV
KSSV 2020 年 9 月 12 日
Edited the answer.
aa
aa 2020 年 9 月 12 日
Thank you this is really amazing and work perfectly, But if i want to get an output file of data points in each grid , how can this be possible.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeANOVA についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by