MATLAB: Output of delaunay function

delaunay triangulationImage Processing Toolbox

My question is two part:
tri=delaunay(M(:,1),M(:,2));
trisurf(tri,M(:,1),M(:,2),M(:,3))
Q.1 How do I interpret the matrix tri?( i want to know how the numbering of the vertices are done.)
Q.2 How do I delete certain triangles after the applying the function delaunay? ( I am not concerned about losing the property of delaunay triangulation. )
Thank You
P.S: I am new to MATLAB and excuse me if the questions I asked are silly.

Best Answer

As per the function documentation, the matrix tri returned from DELAUNAY will be an N-by-3 matrix where N is the number of triangles created. Therefore, each row of tri represents one triangle. The three values for each row represent indices into the set of x and y vertices, which are M(:,1) and M(:,2), respectively, in your example.
For example, consider the case where the first row of tri is [1 2 4]. This defines a triangle whose 3 vertices are at coordinates ( M(1,1), M(1,2)), ( M(2,1), M(2,2)), and ( M(4,1), M(4,2)).
If you want to remove a triangle from tri, all you have to do is remove the given row. For example, if you want to remove the second triangle, you could do this:
tri(2,:) = [];