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

조회 수: 4 (최근 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에서 Contour Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by