Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plot x=y plane in MATLAB

Tags:

matlab

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

  1. I need to create a 21x21 array for Z ( I use surf function.. and the dimensions of X, Y, Z must match. Right?).
  2. I need to populate only those values of Z that follow x==y
  3. Now for each such point i.e. 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.

like image 788
vyi Avatar asked May 13 '26 17:05

vyi


1 Answers

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
enter image description here

like image 156
Shai Avatar answered May 15 '26 14:05

Shai