matlab - 使用 x、y、z 点绘制曲面

标签 matlab plot

我有一个 xyz 的列表,格式如下:

   -0.2894    1.2835    0.5405
   -0.8171   -0.3034    0.1824
    2.7864    0.5506    0.0037

我可以使用 plot3(x,y,z, '*') 绘图,它工作正常。

现在我想画一个表面,但是当我这样做的时候:

>> surf(x,y,z)
??? Error using ==> surf at 78
Z must be a matrix, not a scalar or vector.

我应该怎么画呢?

最佳答案

我建议您对 x,y 值进行 Delaunay 三角剖分,然后使用 z 作为曲面图的高度:

x = randn(100,1);
y = randn(100,1);
z = (exp(-x.^2-y.^2));
tri = delaunay(x,y);
trisurf(tri,x,y,z)

enter image description here

编辑

由于您的 Matlab 版本似乎有问题,这里有一个替代方案:使用 griddata 将您的数据插值到规则网格上,这样您就可以使用 surf密谋。

x = randn(100,1);
y = randn(100,1);
z = (exp(-x.^2-y.^2));
[xx,yy]=meshgrid(-2:0.1:2,-2:0.1:2);
zz = griddata(x,y,z,xx,yy);
dfig,surf(xx,yy,zz)

enter image description here

关于matlab - 使用 x、y、z 点绘制曲面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10272682/

相关文章:

matlab - 约束高阶多项式回归

MATLAB 单元测试函数调用

csv - Gnuplot 在同一时间fmt 中具有不同时间的三个 .csv 文件

wolfram-mathematica - 如何阻止轴调整大小

string - matlab 字符串数组

arrays - 在 Matlab 中向量化和分离查找操作

r - 什么是 matlab 的 csaps() 的 R 等价物

Excel 用连续 x 轴绘制时间序列频率

r - text() 在 R 图中显示带下标的希腊字母

python - Matplotlib:WebAgg 后端不显示任何数字