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

5 ビュー (過去 30 日間)
Krist Mak
Krist Mak 2020 年 7 月 19 日
コメント済み: Krist Mak 2020 年 7 月 23 日
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 件)

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by