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

后端 未结 2 378
悲哀的现实
悲哀的现实 2020-12-06 12:04

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

x = linspace(1,10,100);
y = linspace(10,20,100);

[X Y] = meshgrid(x,y);

Z = X * Y;

surf(X,Y,Z);
         


        
2条回答
  •  执笔经年
    2020-12-06 12:46

    It looks like you've found your answer by using DELAUNAY and TRISURF to generate and plot a triangulated surface.

    As an alternative, you could also fit a regularly-spaced grid to your nonuniformly-spaced points in order to generate a surface that can be plotted with the SURF command. I discuss how this can be done using the TriScatteredInterp class (or the deprecated function GRIDDATA) in my answer to this other question on SO.

提交回复
热议问题