フィルターのクリア

Is it possible to make a surface perfectly proper?

3 ビュー (過去 30 日間)
Ege Ulus
Ege Ulus 2022 年 2 月 6 日
コメント済み: Ege Ulus 2022 年 2 月 14 日
Dear All,
I am getting the graph you see through the code below.
Can I get a plane-like surface with a proper shape like in the attached image without changing the points? I need a proper more evenly shaped surface, even if the surface does not pass through one-to-one points.
D = [288 2.79 7.55;
318 4.64 14.28;
127 2.31 8.31;
132 7.16 17.27;
264 2.31 4.32;
200 2.60 6.74;
268 3.06 15.12];
X = D(:,1);
Y = D(:,2);
Z = D(:,3);
% Create 100x100 grid mesh (x,y) points
[xGrid,yGrid] = meshgrid(linspace(min(X),max(X)),linspace(min(Y),max(Y)));
% Interpolation
zGrid = griddata(X(:),Y(:),Z(:),xGrid(:),yGrid(:),'cubic');
zGrid = reshape(zGrid,size(xGrid));
% Fig.1 Contour plot with original data points
figure
contour(xGrid,yGrid,zGrid,'ShowText','on')
hold on
scatter(X,Y,'ro')
grid on
colorbar
% Fig.2 Surf plot
figure
surf(xGrid,yGrid,zGrid)
colormap(jet)
colorbar
Thanks,
Ege
  2 件のコメント
Image Analyst
Image Analyst 2022 年 2 月 6 日
Do you mean that you want to find the best-fit plane that goes through all those wildly varying points?
Ege Ulus
Ege Ulus 2022 年 2 月 6 日
編集済み: Ege Ulus 2022 年 2 月 6 日
Yes, best fit hyperbolic paraboloid, elliptical, etc. surfaces are also accepted.

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

採用された回答

Burhan Burak AKMAN
Burhan Burak AKMAN 2022 年 2 月 6 日
You can change interpolation method.
zGrid = griddata(X(:),Y(:),Z(:),xGrid(:),yGrid(:),'v4');
  1 件のコメント
Ege Ulus
Ege Ulus 2022 年 2 月 14 日
Thanks, it helped!

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

その他の回答 (2 件)

Simon Chan
Simon Chan 2022 年 2 月 6 日
You may adjust the value of variable 'spacing' in the following code to meet your needs.
I use spacing = 5 as an example, you may try to use 10.
D = [288 2.79 7.55;
318 4.64 14.28;
127 2.31 8.31;
132 7.16 17.27;
264 2.31 4.32;
200 2.60 6.74;
268 3.06 15.12];
X = D(:,1);
Y = D(:,2);
Z = D(:,3);
% Create 100x100 grid mesh (x,y) points
[xGrid,yGrid] = meshgrid(linspace(min(X),max(X)),linspace(min(Y),max(Y)));
% Interpolation
zGrid = griddata(X(:),Y(:),Z(:),xGrid(:),yGrid(:),'cubic');
zGrid = reshape(zGrid,size(xGrid));
% Fig.2 Surf plot
spacing = 5; % Added this variable
figure
surf(xGrid(1:spacing:end,1:spacing:end),yGrid(1:spacing:end,1:spacing:end),zGrid(1:spacing:end,1:spacing:end))
colormap(jet)
colorbar

Image Analyst
Image Analyst 2022 年 2 月 6 日
Try John D'Errico's polyfitn()
It will fit your data to a 2-D polynomial of the order you want, like a plane or parabola.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by