Transform Cartesian to spherical coordinates
[r,theta,phi]=cart2sph(x,y,z)
x,y,z coordinates
radius
elevation angle
azimuth angle
cart2sph(x,y,z) transforms corresponding elements of data stored in Cartesian coordinates X,Y,Z to spherical coordinates (radius r, elevation angle theta, azimuth angle phi). phi and theta are returned in radians. The arrays X,Y, and Z must be the same size (or any of them can be scalar).
add sample pgm