[azimuth,elevation,r]
= cart2sph(x,y,z) transforms corresponding
elements of the Cartesian coordinate arrays x, y,
and z to spherical coordinates azimuth, elevation,
and r.

Convert the Cartesian coordinates defined by corresponding entries in the matrices x, y, and z to spherical coordinates az, el, and r. These points correspond to the eight vertices of a cube.

x = [1 1 1 1; -1 -1 -1 -1]

x =
1 1 1 1
-1 -1 -1 -1

y = [1 1 -1 -1; 1 1 -1 -1]

y =
1 1 -1 -1
1 1 -1 -1

z = [1 -1 1 -1; 1 -1 1 -1]

z =
1 -1 1 -1
1 -1 1 -1

[az,el,r] = cart2sph(x,y,z)

az =
0.7854 0.7854 -0.7854 -0.7854
2.3562 2.3562 -2.3562 -2.3562
el =
0.6155 -0.6155 0.6155 -0.6155
0.6155 -0.6155 0.6155 -0.6155
r =
1.7321 1.7321 1.7321 1.7321
1.7321 1.7321 1.7321 1.7321

Cartesian coordinates, specified as scalars, vectors, matrices,
or multidimensional arrays. x, y,
and z must be the same size, or any of them can
be scalar.

Radius, returned as an array. r is the distance
from the origin to a point. The length units of r are
arbitrary, matching the units of the input arrays x, y,
and z.

The notation for spherical coordinates is not standard. For
the cart2sph function, elevation is
measured from the x-y plane. Notice that if elevation
= 0, the point is in the x-y plane.
If elevation = pi/2, then the point is on the positive z-axis.