Reputation: 3747
I want to plot 2 3D planes for the equations given below :
x + y + z = 1
2x - y = 0
For 1st equation, I plotted it using meshgrid
as :
[x y] = meshgrid(-5:0.5:5);
z = 1 - x - y
mesh(x,y,z)
But for 2nd equation, z is not given i.e. z can be anything, then how do I plot plane for this ?
Upvotes: 1
Views: 11234
Reputation: 2532
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.
[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
Upvotes: 3