cart2sph
- :
[theta, phi, r] =cart2sph(x, y, z)¶ - :
P =cart2sph(x, y, z)¶ Convert Cartesian coordinates to spherical coordinates.
theta is the azimuth (angle in the xy-plane from the positive x axis), phi the elevation (angle above the xy-plane) and r the radius, so that
theta = atan2 (y, x) phi = atan2 (z, hypot (x, y)) r = hypot (hypot (x, y), z)
The inputs must be real floating point arrays of the same size, or scalars. With a single output the result is the N-by-3 matrix
[theta(:), phi(:), r(:)].A single N-by-3 matrix argument (columns x, y, z) is also accepted; a 3-element vector is treated as one point.