# Math Help - 3D plot of z = (Matlab)

1. ## 3D plot of z = (Matlab)

I tried drawing an elliptic paraboloid ( $z = x^2 + y^2$) in Matlab with the following code:

>> [x y] = meshgrid(0 : 5);
>> z = x.^2 + y.^2;
>> surf(z);

However the surface which it produced does not look like an elliptic paraboloid (please refer to the attachment).

2. ## Re: 3D plot of z = (Matlab)

Originally Posted by SyNtHeSiS
However the surface which it produced does not look like an elliptic paraboloid (please refer to the attachment).
It does show an elliptic paraboloid. However you've only plotted a single quadrant of it. Create a meshgrid that spans from -5 to 5 and you'll get the picture that you're looking for.

3. ## Re: 3D plot of z = x^2 + y^2 (Matlab)

Thanks. Why is it that the elliptic paraboloid in Matlab is different to the standard one? (please refer to the attachments).

4. ## Re: 3D plot of z = x^2 + y^2 (Matlab)

Originally Posted by SyNtHeSiS
Thanks. Why is it that the elliptic paraboloid in Matlab is different to the standard one? (please refer to the attachments).
Could you elaborate? Which difference do you mean?

5. ## Re: 3D plot of z = x^2 + y^2 (Matlab)

Originally Posted by corsica
Could you elaborate? Which difference do you mean?
I think he is petrubed by the square in the x-y plane that the surface is plotted above giving the plotted part of the surface peaks at the corners rather than the circular form of the top edge of the plotted part of the surface in the second plot.

try something like:

Code:
>> [r,the]=meshgrid([0:0.1:5],[0:pi/10:2*pi]);
>> x=r.*cos(the);
>> y=r.*sin(the);
>> z=x.^2+y.^2;
>> surf(x,y,z);
CB