cart2pol

Purpose

Transform Cartesian coordinates to polar.

Synopsis

[theta,rho] = cart2pol(x,y)
[theta,rho,z] = cart2pol(x,y,z)

Description

[theta,rho] = cart2pol(x,y) transforms data stored in Cartesian, or xy, coordinates to polar coordinates. x and y must be the same size. theta is in radians.

[theta,rho,z] = cart2pol(x,y,z) transforms data stored in Cartesian coordinates to cylindrical coordinates. x, y, and z must be the same size.

Examples

t = 0:.01:2*pi;
x = cos(t).*cos(2*t).*sin(2*t);
y = sin(t).*cos(2*t).*sin(2*t);
plot(x,y), title('Cartesian')
          

[theta,rho] = cart2pol(x,y); polar(theta,rho), title('Polar')

See Also

cart2sph, pol2cart, sph2cart

(c) Copyright 1994 by The MathWorks, Inc.