sphere
Generates the coordinates of a unit sphere, or draws it.
Category: Graphics > 2-D and 3-D Plots
Syntax
sphere
Draws a unit sphere with 20 panels per direction.
sphere(n)
Draws a sphere with n panels per direction.
[X, Y, Z] = sphere(n)
Returns the coordinate matrices without drawing.
Description
The points are spaced evenly in longitude and latitude, so the output can be passed to surf or mesh. Scale and shift the matrices to get another radius or center, for instance surf(2*X + 1, 2*Y, 2*Z).
Input arguments
n- Number of panels in each direction. The default is 20.
Output arguments
X, Y, Z- Matrices of size
(n+1)-by-(n+1)with the points of the sphere, centered at the origin with radius 1.
Example
Coordinates of a sphere
[X, Y, Z] = sphere(10);
disp(size(X))
disp(max(Z(:)))
disp(min(Z(:)))
Output
11 11
1
-1