Skip to content

sphere

Generate coordinate matrices for a unit sphere.

[X, Y, Z] = sphere
[X, Y, Z] = sphere(n)

Returns (n+1) × (n+1) coordinate matrices for a unit sphere — pass to surf or mesh to render. Default n = 20 (smoother spheres need higher n). Without output arguments, plots directly.

sphere(50) % render a 50-faceted sphere directly
[X, Y, Z] = sphere(30); surf(X, Y, Z)
  • cylinder — Generate coordinate matrices for a unit cylinder.
  • surf — 3D surface plot with colored faces.