
How to interplote and meshgrid 2D scatter plot (bounded by an ir-regular surface)?
14 ビュー (過去 30 日間)
表示 古いコメント
Hi everyone,
I require interpolating a 2d scatter plot and then creating a mesh grid to find the average value within each grid cell along with the cell's central location.
Here is what i did so far:
Step 1: Plotting irregular surface
data=readmatrix('area.csv');
x=data(:,1);
y=data(:,2);
z=data(:,3);
plot(x, y, 'blue')
hold on

Step 2: Scatter plot
dat=readmatrix('combine.csv');
x1=dat(:,2);
y1=dat(:,3);
c1=dat(:,4);
plot(x1, y1, 'blue')
scatter(x1,y1,[],c1,'filled')
colorbar
colormap jet
hold off

To do ?
I require to plot these scatter pl;ot by interploation to get a higher resolution, like as below:

Additionally, I need to creat a mesh grid with teh bounded area and need to calcualte the depth value within each grid point along with the central location of grid.
Thank you!
(Data is attached).
0 件のコメント
採用された回答
Mathieu NOE
2023 年 5 月 22 日
hello
this should help you move forward
side by side the original plot and once resampled (grid data)

% Step 1: Plotting irregular surface
data=readmatrix('area.csv');
x=data(:,1);
y=data(:,2);
z=data(:,3);
plot(x, y, 'blue')
hold on
% Step 2: Scatter plot
dat=readmatrix('combine.csv');
x1=dat(:,2);
y1=dat(:,3);
c1=dat(:,4);
% plot(x1, y1, 'blue')
subplot(1,2,1),
scatter(x1,y1,[],c1,'filled')
title('original data')
colorbar
colormap jet
hold off
% create a mesh , and find points that are inside the border defined by x &
% y
N = 200;
[X,Y] = meshgrid(linspace(min(x),max(x),N),linspace(min(y),max(y),N));
in = inpolygon(X(:),Y(:),x,y);
xin = X(in);
yin = Y(in);
clear X Y
vq = griddata(x1,y1,c1,xin,yin);
subplot(1,2,2),
scatter(xin, yin, [], vq, 'filled')
title('resampled data')
colorbar
colormap jet
hold off
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Colormaps についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!