简体   繁体   English

在 Matlab 中绘制 3d 数据

[英]plot 3d data in Matlab

I'm trying to plot data on a 3D graph using the waterfall function.我正在尝试使用瀑布函数在 3D 图形上绘制数据。 Here's some example code that isn't working properly:以下是一些无法正常工作的示例代码:

x=0:.1:1;
y(1,:) = exp(x);
y(2,:) = exp(2*x);
z = [1,2];
waterfall(x,y,z);

I'm trying to plot each curve on it's own z dimension, but I'm not formatting the waterfall command properly.我试图在它自己的 z 维度上绘制每条曲线,但我没有正确格式化瀑布命令。 I think I could also use a "mesh" function, but I can't get that working either.我想我也可以使用“网格”功能,但我也无法使用。

This is the answer这就是答案

x=0:.1:1;
Z(1,:) = exp(x);
Z(2,:) = exp(2*x);
[X,Y] = meshgrid(x,1:size(Z,1));
waterfall(X,Y,Z)

I think you can use:我认为你可以使用:

x=0:.1:1;
y(1,:) = exp(x);
y(2,:) = exp(2*x);
z = [1,2];
hold on
plot(x,y(1,:),z(1))
plot(x,y(2,:),z(2))

But I'm not sure if that's your desired output.但我不确定这是否是您想要的输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM