How to draw a 3D surface with all the given discrete points?
Mostra commenti meno recenti
I am trying to draw data from several curves into a 3D surface. I have extracted the points in the curves as discrete data points and tried to draw a surface plot based on scatter data. The problem is that discrete points in each curve may have multiple Z-values at the same X-Y coordinate. Command 'griddata' and 'surf' have been used, but it gives warning of duplicate data points have been detected and averaged.
I have realized that the rule of 'griddata' is that only the unique Z-value can be used in the xy plane, otherwise the average will be used. The data is contained in the attachment, and the code and results are given below.
close all; clear all
load XYZ_data
scatter3(x,y,z)
% figure
[X,Y,Z]=griddata(x,y,z,linspace(min(x),max(x))',linspace(min(y),max(y)),'v4');
figure,surf(X,Y,Z);
figure,meshc(X,Y,Z)
How can I get a smooth surface with all the given data? Any comments will be much appreciated.


Risposta accettata
Più risposte (1)
load(websave("XYZ_data.mat", "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1559554/XYZ_data.mat"))
whos
figure
T = delaunay(x, y);
% Seems that there are duplicate point for x, y (in addition to z?)
trisurf(T, x, y, z, "EdgeColor","none", "FaceColor","interp");
xlabel("x"); ylabel("y")
view(80, 30)
1 Commento
Danny
il 4 Dic 2023
Categorie
Scopri di più su Surface and Mesh Plots in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

