[英]Plot 3D plane given equations in matlab
I want to plot 2 3D planes for the equations given below : 我想为下面给出的等式绘制2个3D平面:
x + y + z = 1
2x - y = 0
For 1st equation, I plotted it using meshgrid
as : 对于第一个等式,我使用
meshgrid
绘制它:
[x y] = meshgrid(-5:0.5:5);
z = 1 - x - y
mesh(x,y,z)
But for 2nd equation, z is not given ie z can be anything, then how do I plot plane for this ? 但对于第二个等式,z没有给出,即z可以是任何东西,那么我如何为此绘制平面?
The comments are correct. 评论是正确的。 It is more of a math problem.
这更像是一个数学问题。 You draw a line
2x - y = 0
and translate it for any z
value to create a plane. 您绘制一条直线
2x - y = 0
并将其转换为任何z
值以创建平面。
[x, y] = meshgrid(-5:0.5:5);
Zv = @(x,y) 1 - x - y;
mesh(x,y,Zv(x,y));
hold on
[x, z] = meshgrid(-5:0.5:5);
Yv = @(x) 2*x;
mesh(x,Yv(x),z);
hold off
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.