I am attempting to plot 3D surfaces in MATLAB, and I made use of meshgrid
, similar to what the MATLAB tutorials said here: http://www.mathworks.com/help/matlab/ref/meshgrid.html
I wrote a very simple three line script that I believed would produce the surface z = x + y and it is as follows:
[x , y] = meshgrid( linspace( 0 , 10 , 10 ) , linspace( 0 , 10 , 10 ) );
z = x + y;
surf( [ x , y , z] );
From what I understand, line 1 produces all combinations of (x,y) coordinates evenly spaced from 0 to 10. Then line 2 just applies the formula z = x + y
to that exhaustive list of combinations. Then line 3 just plots all the (x, y, z)
points.
But I got the following "thing" as output:
I'm pretty sure the graph in the above picture is not z = x + y
, and I have no clue why there aren't two axes going up to maximum value 10.
Still, I find the script too simple and couldn't see anything wrong with it. Could anyone point out where I overlooked something? Thank you.