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)?

1
  • 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') Commented Sep 19, 2014 at 12:08

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

7 Comments

yes, I included it, the color is determined by the "surface height" which is the lowest or bottom value.
But why you choose plot3(2, 0.2, 12, 'ro'). Why not other one ?
because you requested it?
If I would like to plot 2 points. ? In other words, to observe 2 ot more points on the surface
you haven't forgot hold on? it isn't hidden behind the surface?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.