How to do surface plot from given set of data?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Prakash Chettri
el 31 de Mzo. de 2022
Comentada: KSSV
el 31 de Mzo. de 2022
I have X and Y and Z coordinates. Now i want ro do surface plot of these data, I used surf() command but its showing error. can anyone give idea how can i plot the data. I have add data for the reference.
2 comentarios
Mahmoud Ashraf
el 31 de Mzo. de 2022
if the values x,y,and z is a coordinates of point i think we shoud use 3d plot instead of surface or used this line
load Data.txt % after we remove the chararcter from the txt file
surf(data);
Respuesta aceptada
KSSV
el 31 de Mzo. de 2022
Editada: KSSV
el 31 de Mzo. de 2022
T = readtable('data.txt') ;
x = T.(1) ;
y = T.(2) ;
z = T.(3) ;
% Plot as unstructured grid
dt = delaunayTriangulation(x,y) ;
p = dt.Points ;
tri = dt.ConnectivityList ;
F = scatteredInterpolant(x,y,z) ;
z = F(p(:,1),p(:,2)) ;
figure(1)
trisurf(tri,p(:,1),p(:,2),z)
view(2)
shading interp
% Plot as structured grid
xi = linspace(min(x),max(x),300) ;
yi = linspace(min(y),max(y),300) ;
[X,Y] = meshgrid(xi,yi) ;
Z = griddata(x,y,z,X,Y) ;
figure(2)
pcolor(X,Y,Z) ;
shading interp
4 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!