www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/CartesianToSphericalCoordinatesExample.m
%% Cartesian to Spherical Coordinates % 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] %% y = [1 1 -1 -1; 1 1 -1 -1] %% z = [1 -1 1 -1; 1 -1 1 -1] %% [az,el,r] = cart2sph(x,y,z)