Reputation: 1092
I fail to think how should I proceed for plotting x=y
plane withing a 2x2x2 space.
I create a 2x2 meshgrid
[X,Y]=meshgrid(-1:0.1:1,-1:0.1:1);
then I come to define Z
- I get stuck
My thoughts go like this
surf
function.. and the dimensions of X, Y, Z must match. Right?). x==y
x==y
Z will vary -1:0.1:1
.. Does This require that I iterate again and again on the x==y
and keep drawing Z with values from -1:0.1:1
?Am I going the right way about plotting this plane? Kindly help.
Upvotes: 3
Views: 1284
Reputation: 21563
You are actually trying to do something two dimensional in a 3 dimensional setting.
A bit unintuitive, but that does not mean it can't be done, for example:
[X,Y]=meshgrid(-1:0.1:1,-1:0.1:1);
Z = zeros(size(X)); % Perhaps you want NaN rather than zeros
idx = X==Y;
Z(idx)=X(idx).^2+Y(idx) % Of course identical to X(idx).^2+X(idx)
surf(Z)
Upvotes: 1
Reputation: 114806
You simply need to define X
and Z
, Y
is equal to X
by definition:
[X Z] = meshgrid(-1:.1:1,-1:.1:1);
figure;
surf(X,X,Z);xlabel('x');ylabel('y');zlabel('z');
Results with
Upvotes: 9