1

As in this link, I have:

      | 0.1  0.2  0.3  0.4
    ----------------------
    1 | 10   11   12   13
    2 | 11   12   13   14
    3 | 12   13   14   15
    4 | 13   14   15   16

    Y = [0.1 0.2 0.3 0.4];
    X = [1 2 3 4];
    Z = [10 11 12 13; 11 12 13 14; 12 13 14 15; 13 14 15 16];

I plotted the surface Z using the command "surf(X,Y,Z)" in matlab. I got:

enter image description here

But really I don't understand the plotted surface. Can someone explain to me in details (in a text) what happens in this surface? For example: how can we observe the point (2,0.2,12)?

Community
  • 1
  • 1
Christina
  • 903
  • 16
  • 39
  • 2
    To identify individual points you could plot them in the picture. Maybe try: *hold on; plot3(2,0.2,12,'ro')*. Additional you could add labels to the plot: *xlabel('x'); ylabel('y'); zlabel('z')* – zinjaai Sep 19 '14 at 12:08

1 Answers1

5

Include some labels and a colorbar and everything should be clear:

Y = [0.1 0.2 0.3 0.4];
X = [1 2 3 4];
Z = [10 11 12 13; 11 12 13 14; 12 13 14 15; 13 14 15 16];

surf(X,Y,Z)
colorbar
xlabel('X')
ylabel('Y')
zlabel('Z')

As suggested in the comments you can find your point on the surface by adding:

hold on;
plot3(2,0.2,12,'ro','MarkerSize',10,'MarkerFaceColor','r');

it then appears as a red dot.

enter image description here

Your table contains 16 points, these are plotted and the area inbetween, colored according to the applied colormap with the lowest z-value of the group of 4, which is according to the doc the surface height.

Actually it would be cleaner coding if you'd include the following line before the plot:

[X,Y] = meshgrid(X,Y);

this way all your input variables get the same dimensions:

X =
     1     2     3     4
     1     2     3     4
     1     2     3     4
     1     2     3     4

Y =
          0.1          0.1          0.1          0.1
          0.2          0.2          0.2          0.2
          0.3          0.3          0.3          0.3
          0.4          0.4          0.4          0.4

Z =
    10    11    12    13
    11    12    13    14
    12    13    14    15
    13    14    15    16

In case of surf the function does that for you, but other plotting functions are may not that tolerant.

Robert Seifert
  • 25,078
  • 11
  • 68
  • 113