sphere
Creates and plots a 3D unit sphere.
Syntax
sphere()
sphere(N)
sphere(hAxes, ...)
[x, y, z] = sphere(...)
Inputs
- N
- Number of horizontal and vertical segments. Default value is 20.
- hAxes
- Axis handle.
Outputs
- x, y, z
- Sphere coordinates.
Examples
Default sphere:
figure();
sphere();
Plot a sphere with 10 segments:
figure();
sphere(10);
Get the sphere coordinates without plotting the sphere:
[x, y, z] = sphere();
x = [Matrix] 9 x 9
0.00000e+00 0.00000e+00 0.00000e+00 -0.00000e+00 -0.00000e+00 -0.00000e+00 -0.00000e+00 0.00000e+00 0.00000e+00
3.82683e-01 2.70598e-01 2.34326e-17 -2.70598e-01 -3.82683e-01 -2.70598e-01 -7.02978e-17 2.70598e-01 3.82683e-01
7.07107e-01 5.00000e-01 4.32978e-17 -5.00000e-01 -7.07107e-01 -5.00000e-01 -1.29893e-16 5.00000e-01 7.07107e-01
9.23880e-01 6.53281e-01 5.65713e-17 -6.53281e-01 -9.23880e-01 -6.53281e-01 -1.69714e-16 6.53281e-01 9.23880e-01
1.00000e+00 7.07107e-01 6.12323e-17 -7.07107e-01 -1.00000e+00 -7.07107e-01 -1.83697e-16 7.07107e-01 1.00000e+00
9.23880e-01 6.53281e-01 5.65713e-17 -6.53281e-01 -9.23880e-01 -6.53281e-01 -1.69714e-16 6.53281e-01 9.23880e-01
7.07107e-01 5.00000e-01 4.32978e-17 -5.00000e-01 -7.07107e-01 -5.00000e-01 -1.29893e-16 5.00000e-01 7.07107e-01
3.82683e-01 2.70598e-01 2.34326e-17 -2.70598e-01 -3.82683e-01 -2.70598e-01 -7.02978e-17 2.70598e-01 3.82683e-01
1.22465e-16 8.65956e-17 7.49880e-33 -8.65956e-17 -1.22465e-16 -8.65956e-17 -2.24964e-32 8.65956e-17 1.22465e-16
y = [Matrix] 9 x 9
0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 -0.00000e+00 -0.00000e+00 -0.00000e+00 -0.00000e+00
0.00000e+00 2.70598e-01 3.82683e-01 2.70598e-01 4.68652e-17 -2.70598e-01 -3.82683e-01 -2.70598e-01 -9.37304e-17
0.00000e+00 5.00000e-01 7.07107e-01 5.00000e-01 8.65956e-17 -5.00000e-01 -7.07107e-01 -5.00000e-01 -1.73191e-16
0.00000e+00 6.53281e-01 9.23880e-01 6.53281e-01 1.13143e-16 -6.53281e-01 -9.23880e-01 -6.53281e-01 -2.26285e-16
0.00000e+00 7.07107e-01 1.00000e+00 7.07107e-01 1.22465e-16 -7.07107e-01 -1.00000e+00 -7.07107e-01 -2.44929e-16
0.00000e+00 6.53281e-01 9.23880e-01 6.53281e-01 1.13143e-16 -6.53281e-01 -9.23880e-01 -6.53281e-01 -2.26285e-16
0.00000e+00 5.00000e-01 7.07107e-01 5.00000e-01 8.65956e-17 -5.00000e-01 -7.07107e-01 -5.00000e-01 -1.73191e-16
0.00000e+00 2.70598e-01 3.82683e-01 2.70598e-01 4.68652e-17 -2.70598e-01 -3.82683e-01 -2.70598e-01 -9.37304e-17
0.00000e+00 8.65956e-17 1.22465e-16 8.65956e-17 1.49976e-32 -8.65956e-17 -1.22465e-16 -8.65956e-17 -2.99952e-32
z = [Matrix] 9 x 9
-1.00000e+00 -1.00000e+00 -1.00000e+00 -1.00000e+00 -1.00000e+00 -1.00000e+00 -1.00000e+00 -1.00000e+00 -1.00000e+00
-9.23880e-01 -9.23880e-01 -9.23880e-01 -9.23880e-01 -9.23880e-01 -9.23880e-01 -9.23880e-01 -9.23880e-01 -9.23880e-01
-7.07107e-01 -7.07107e-01 -7.07107e-01 -7.07107e-01 -7.07107e-01 -7.07107e-01 -7.07107e-01 -7.07107e-01 -7.07107e-01
-3.82683e-01 -3.82683e-01 -3.82683e-01 -3.82683e-01 -3.82683e-01 -3.82683e-01 -3.82683e-01 -3.82683e-01 -3.82683e-01
6.12323e-17 6.12323e-17 6.12323e-17 6.12323e-17 6.12323e-17 6.12323e-17 6.12323e-17 6.12323e-17 6.12323e-17
3.82683e-01 3.82683e-01 3.82683e-01 3.82683e-01 3.82683e-01 3.82683e-01 3.82683e-01 3.82683e-01 3.82683e-01
7.07107e-01 7.07107e-01 7.07107e-01 7.07107e-01 7.07107e-01 7.07107e-01 7.07107e-01 7.07107e-01 7.07107e-01
9.23880e-01 9.23880e-01 9.23880e-01 9.23880e-01 9.23880e-01 9.23880e-01 9.23880e-01 9.23880e-01 9.23880e-01
1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00 1.00000e+00
Comments
If there is no axes, one will be created first. If the first argument is an axes handle, the sphere will be created in that axes.
With return values assigned, sphere will not plot the sphere. The sphere plot can be created with the command 'surf(x, y, z)'.