How can I create a three-dimensional surface from unsorted coordinates in MATLAB 7.4 (R2007a)?

4 views (last 30 days)
I have vectors of X, Y and Z coordinates which are not sorted according to the nearest neighbor criterion. I would like to be able to create and render a surface using this data using in-built functions in MATLAB. Would this data be usable with the SURF function?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The function SURF expects a neat rectilinear grid to be supplied to it before it can render the surface. It is not possible to use this function directly to render a surface with unordered coordinates.
As a workaround the function TRISURF can be used to create the surface in conjunction with the DELAUNAY function. The DELAUNAY function performs the triangulation and returns a mx3 matrix "Tri" which defines each triangle used to render the surface. Each row of "Tri" defines a single triangular face by indexing into the vectors or matrices that contain the X, Y, and Z vertices. This "Tri" matrix can then be used with TRISURF to generate the surface.
The following code illustrates the use of DELAUNAY and TRISURF to generate a surface:
load seamount;
tri = delaunay(x,y);
h = trisurf(tri, x, y, z);
axis off
l = light('Position',[-50 -15 29])
set(gca,'CameraPosition',[208 -50 7687])
lighting phong
shading interp
colorbar EastOutside
axis vis3d

More Answers (0)

Categories

Find more on Delaunay Triangulation in Help Center and File Exchange

Products


Release

R2007a

Community Treasure Hunt

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

Start Hunting!