I am trying to draw a sphere in Matlab without using the Sphere Function. This is my code:
r = 2;
[ x,y ] = meshgrid(-4:0.1:4);
z = sqrt(r^2-x.^2-y.^2);
mesh(real(z));
hold on
mesh(real(-z));
The code above does generate a sphere of equation r^2=x^2+y^2+z^2. The only problem is that there is a horizontal plane slicing the sphere.
My question is how can I plot a sphere that doesn't show the horizontal plane?
The reason I am not using a Sphere function is because I want to plot a surface equation. If I use the Sphere function then Matlab assumes my surface will be a sphere.