Next: , Previous: , Up: Arithmetic   [Contents][Index]

### 17.8 Coordinate Transformations

: [theta, r] = cart2pol (x, y)
: [theta, r, z] = cart2pol (x, y, z)
: [theta, r] = cart2pol (C)
: [theta, r, z] = cart2pol (C)
: P = cart2pol (…)

Transform Cartesian coordinates to polar or cylindrical coordinates.

The inputs x, y (, and z) must be the same shape, or scalar. If called with a single matrix argument then each row of C represents the Cartesian coordinate (x, y (, z)).

theta describes the angle relative to the positive x-axis.

r is the distance to the z-axis (0, 0, z).

If only a single return argument is requested then return a matrix P where each row represents one polar/(cylindrical) coordinate (theta, phi (, z)).

: [x, y] = pol2cart (theta, r)
: [x, y, z] = pol2cart (theta, r, z)
: [x, y] = pol2cart (P)
: [x, y, z] = pol2cart (P)
: C = pol2cart (…)

Transform polar or cylindrical coordinates to Cartesian coordinates.

The inputs theta, r, (and z) must be the same shape, or scalar. If called with a single matrix argument then each row of P represents the polar/(cylindrical) coordinate (theta, r (, z)).

theta describes the angle relative to the positive x-axis.

r is the distance to the z-axis (0, 0, z).

If only a single return argument is requested then return a matrix C where each row represents one Cartesian coordinate (x, y (, z)).

: [theta, phi, r] = cart2sph (x, y, z)
: [theta, phi, r] = cart2sph (C)
: S = cart2sph (…)

Transform Cartesian coordinates to spherical coordinates.

The inputs x, y, and z must be the same shape, or scalar. If called with a single matrix argument then each row of C represents the Cartesian coordinate (x, y, z).

theta describes the angle relative to the positive x-axis.

phi is the angle relative to the xy-plane.

r is the distance to the origin (0, 0, 0).

If only a single return argument is requested then return a matrix S where each row represents one spherical coordinate (theta, phi, r).

: [x, y, z] = sph2cart (theta, phi, r)
: [x, y, z] = sph2cart (S)
: C = sph2cart (…)

Transform spherical coordinates to Cartesian coordinates.

The inputs theta, phi, and r must be the same shape, or scalar. If called with a single matrix argument then each row of S represents the spherical coordinate (theta, phi, r).

theta describes the angle relative to the positive x-axis.

phi is the angle relative to the xy-plane.

r is the distance to the origin (0, 0, 0).

If only a single return argument is requested then return a matrix C where each row represents one Cartesian coordinate (x, y, z).