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)