double surface using scatteredInterpolant

1 回表示 (過去 30 日間)
JustANickName
JustANickName 2022 年 7 月 14 日
コメント済み: JustANickName 2022 年 7 月 14 日
Hi,
I'm trying to make a 3-D plot with contour from a datafile that contains 1500 point in 3 column {x,y,z}, where z=f(x,y). The following code is what I use to generate the plot, and a,b contains the x,y of my file. As you can see from the following images in the 3d plot there's the overlap between two surface: a curved one (it's the one that should be my funciton) and a "roof" over it given by the parasite linear surface. Indeed, also the contour plot show the overlap between this surface. I cannot use scatter3 function because I need the contour plot that can be done only with an interpolation function of my data. How can I solve it? I'm quite new to matlab. Thanks.
load zoccolo.txt
a = zoccolo(:,1);
b = zoccolo(:,2);
z = zoccolo(:,3);
[X Y] = ndgrid(a,b);
F=scatteredInterpolant(a,b,z);
Z = F(X,Y);
tmp = surf(X,Y,Z);
rotate(tmp,[0 0 1],180)
contour(X,Y,Z,100);

採用された回答

KSSV
KSSV 2022 年 7 月 14 日
T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1065115/zoccolo.txt') ;
zoccolo = table2array(T) ;
a = zoccolo(:,1);
b = zoccolo(:,2);
z = zoccolo(:,3);
x = linspace(min(a),max(a));
y = linspace(min(b),max(b));
[X,Y] = meshgrid(x,y) ;
Z = griddata(a,b,z,X,Y) ;
surf(X,Y,Z)
  1 件のコメント
JustANickName
JustANickName 2022 年 7 月 14 日
It works like a charm, thanks!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by