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

后端 未结 2 380
悲哀的现实
悲哀的现实 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:43

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

    You can use the trisurf function:

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

    If you have dense data you will want to do shading interp (or another value, check doc shading) so you don't get a black blob due to the grid.

提交回复
热议问题