plotting two curves/planes, one on top of another in Matlab?

1 次查看(过去 30 天)
For e.g I have two curves say, sin(x) and cos(x), using hold on plots both of them in the figure. But then, how can I place one of them on top of another such that when I use Rotate 3-D both of them are visible at some distance from each other(height).

回答(2 个)

Image Analyst
Image Analyst 2016-3-6
编辑:Image Analyst 2016-3-6
Plot using plot3(). Have a different z value for each curve so that they are separated along the z dimension.
x = linspace(0, 3*pi, 200);
y1 = cos(x);
y2 = sin(x);
z1 = 2*ones(1, length(y1));
z2 = 4*ones(1, length(y1));
plot3(x, y1, z1, 'LineWidth', 2);
hold on;
plot3(x, y2, z2, 'LineWidth', 2);
grid on;

Ced
Ced 2016-3-6
编辑:Ced 2016-3-6
hold on is still the way to go. Matlab will (should) always plot things where you define them. So, if you define sin(x) and cos(x) in the (x,y) plane, this inherently means that z = 0 ( for both of them). If you want to set z too, use plot3(x,y,z) instead of plot(x,y).

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by