How to plot 2d & 3d contour with xy coordinates with corresponding z values?

1 次查看(过去 30 天)
I am modelling an embankment data at the moment. I want to plot a contour graph from 3 columns data that would look similar to the one shown below. Turned out the plot had some unnecessary linkages and the mesh was too dense that I could not really see what was happening at the top of the embankment. The codes under are the ones I tried in Matlab. How can I make a nice 2d or 3d contour graph that I want? As an example, one of my dataset is attached below. Thank you so much.
trial=meshdata{:,:}
x = trial(:,1) ; y = trial(:,2) ; z = trial(:,3) ;
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
figure
trisurf(tri,x,y,z)

采纳的回答

jonas
jonas 2020-7-19
If you had the geometry saved, e.g. as .stl file, then you could just pass some constraints to the delunayTriangulation. However, a small problem is that your edges are not straight, so it becomes difficult to define cornerpoints.
Here's another method you could try:
xyz = readmatrix('mesh data.xlsx');
[x,y,z] = deal(xyz(:,1),xyz(:,2),xyz(:,3))
% alphashape to get tight boundary without holes
shp = alphaShape(x,y,'holethreshold',1e5);
% plot edges
edges = boundaryFacets(shp);
plot(x(edges),y(edges),'k','linewidth',2);hold on
%get connectivity
tri = alphaTriangulation(shp);
t = trisurf(tri,x,y,z);
t.EdgeColor = 'none'
view(2)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by