How to make a surf plot in MATLAB with irregularly spaced data?

I know that I can create a 3D surface graph in MATLAB by doing:

x = linspace(1,10,100); y = linspace(10,20,100); [XY] = meshgrid(x,y); Z = X * Y; surf(X,Y,Z); 

But this requires that all nodes of the created height map be lined up. I have a dataset that has arbitrary points (x, y) and height (z). Is there an easy way to build a graph that will generate a surface between points like surf ?

+7
matlab plot 3d
source share
2 answers

Recalls, after some hunting I managed to answer my own question:

You can use trisurf function:

 tri = delaunay(x,y); trisurf(tri,x,y,z); 

If you have dense data, you want to make a shading interp (or other value, check doc shading ) so that you don't get a black drop due to the grid.

+9
source share

It looks like you found your answer using DELAUNAY and TRISURF to create and build a triangulated surface.

Alternatively, you can also place the grid at regular intervals at your unevenly spaced points to create a surface that can be applied using SURF . I discuss how this can be done using the TriScatteredInterp class (or the legacy GRIDDATA function) in my answer to this other question about SO .

+3
source share

All Articles