pol2cart

Converts polar or cylindrical coordinates to Cartesian.

Category: Mathematics > Elementary Math

Syntax

[x, y] = pol2cart(theta, rho)

Converts polar coordinates (angle theta in radians, radius rho) to x and y.

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

Converts cylindrical coordinates; the height z passes through unchanged.

Description

The conversion is x = rho.*cos(theta) and y = rho.*sin(theta). Inputs must have compatible sizes, and a scalar is expanded to match an array, so one radius can serve many angles.

Because of rounding, results that should be zero often appear as tiny values like 6.1232e-17. The inverse conversion is cart2pol.

Input arguments

theta
Angle in radians, measured counterclockwise from the positive x axis.
rho
Distance from the origin (or from the z axis in cylindrical coordinates).
z
Height, for the cylindrical form.

Output arguments

x, y, z
Cartesian coordinates, with the size given by implicit expansion of the inputs.

Example

Points on a circle

theta = [0 pi/2 pi];
[x, y] = pol2cart(theta, 2);
round([x; y], 10)
Output
ans = 2×3

     2     0    -2
     0     2     0

See also

cart2pol sph2cart cart2sph cos sin