Method on @sym: [theta, r] = cart2pol (x, y)
Method on @sym: [theta, r, z] = cart2pol (x, y, z)
Method on @sym: [theta, r] = cart2pol (C)
Method on @sym: [theta, r, z] = cart2pol (C)

Transform symbolic Cartesian coordinates into polar or cylindrical.

If called with inputs x, y (and z), they must be of the same shape or a scalar. The shape of the outputs theta, r (and z) matches those of the inputs (except when the input is a scalar).

If called with a single input C, it must be a column vector with 2 or 3 entries, or a matrix with 2 or 3 columns. The column vector or each row of the matrix represents a point in Cartesian coordinates (x, y) or (x, y, z). If input C is a column vector, outputs theta, r (and z) is a scalar. Otherwise, the shape of the outputs theta, r (and z) is a column vector with each row corresponding to that of the input matrix C.

Given a point (x, y) in Cartesian coordinates, its corresponding polar coordinates can be obtained by:

syms x y real
[theta, r] = cart2pol (x, y)
  ⇒ theta = (sym) atan2(y, x)
    r = (sym)
         _________
        ╱  2    2
      ╲╱  x  + y

Similarly, given a point (x, y, z) in Cartesian coordinates, its corresponding cylindrical coordinates can be obtained by:

syms x y z real
[theta, r, z] = cart2pol (x, y, z)
  ⇒ theta = (sym) atan2(y, x)
    r = (sym)
         _________
        ╱  2    2
      ╲╱  x  + y
    z = (sym) z

See also: cart2pol.

Package: symbolic