简体   繁体   中英

Plot surface from irregular data

I'm make a filled contour or surface plot from a scattered dataset.

A major difference from other Qs is that the data are not convex.

[r,th] = meshgrid(10:15,0:180);
[x,y] = deal(r.*sind(th), r.*cosd(th));
z = x.^2+y.^2;
scatter(x(:),y(:),[],z(:),'fill'); axis equal off;

The inner circle is null.

在此输入图像描述

I use

tri = delaunay(x,y);
trisurf(tri,x,y,z);  view(2); axis equal off;

to make a surface plot.

However, as you can see, the inner circle is filled.

在此输入图像描述

Rather than using the Delaunay triangulation which results in the convex hull, you're going to want to use an alphaShape with which you can impose a limit on the length of the resulting surfaces edges.

You can specify the Alpha property (by specifying a third input) which is the inverse of the maximum edge length. For your example, I've chosen an Alpha of 1.

A = alphaShape(x(:), y(:), 1);

You can then get the triangulation out using the alphaTriangulation method of your alphaSurface object.

[faces, vertices] = A.alphaTriangulation();
zvalue = sum(vertices.^2, 2);

Or you can use the plot method of the alphaShape object

plot(A, 'FaceColor', 'interp', 'CData', zvalue)

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM