MATLAB: 2D & 3D Delaunay Triangulation of data

delaunaydelaunaytriangulation

I'm working on a surface etching model for a research project. I want to model a surface by using MATLABs delaunay or delaunayTriangulation functions. I've been able to produce the surface that I want using delaunay, and the following code:
if true
[x,y] = meshgrid(0:10,0:10);
z = ones(size(x));
tri = delaunay(x,y);
trisurf(tri,x,y,z);
end
Which yields the following surface:
However, the delaunay function will not allow me to access the vertices of the triangles so that I can perform the "etching" reaction. I know that I need to use delaunayTriangulation(). But I'm having trouble reproducing the same results that I have with delaunay(). I've tried this code:
if true
x = 0:10;
y = 0:10;
tri = delaunayTriangulation(x,y);
end
It outputs a triangulation that does not have any "Connectivity List" but only a 11:2 double. How can I remedy this, and create a surface similar to that of the delaunay() function? I've also tried using:
if true
x = 0:10;
y = 0:10;
z = ones([1 11]);
tri = delaunayTriangulation(x,y,z);
end
With the same result. Once I get this going, I'll be inputing a nanoscale scan of a metallic surface so that I can simulate a diffusion reaction. I'm just starting with this, so that I can learn how to manipulate the triangles and the vertices.

Best Answer

You can get the triangle coordinates from the delaunay output.
[x,y] = meshgrid(0:10,0:10);
z = ones(size(x));
tri = delaunay(x,y);
trisurf(tri,x,y,z);
tri_num = [5, 9]; %name some specific triangles
tx = x(tri(tri_num,:)); %get their coordinates
ty = y(tri(tri_num,:));
tz = z(tri(tri_num,:));
txc = [tx, tx(:,1)]; %close them for plotting
tyc = [ty, ty(:,1)];
tzc = [tz, tz(:,1)];
hold on
plot3(txc.', tyc.', tzc.', 'r');
hold off
Or in short, the unclosed coordinates for all of the triangles at the same time are
tx = x(tri);
ty = y(tri);
tz = z(tri);