Transform polar or cylindrical coordinates to Cartesian
collapse all in page
Syntax
[x,y] =pol2cart(theta,rho)
[x,y,z]= pol2cart(theta,rho,z)
Description
example
[x,y] =pol2cart(theta,rho)
transformscorresponding elements of the polar coordinate arrays theta
and rho
totwo-dimensional Cartesian, or xy, coordinates.
example
[x,y,z]= pol2cart(theta,rho,z)
transformscorresponding elements of the cylindrical coordinate arrays theta
, rho
,and z
to three-dimensional Cartesian, or xyz,coordinates.
Examples
collapse all
Polar to Cartesian Coordinates
Open Live Script
Convert the polar coordinates defined by corresponding entries in the matrices theta
and rho
to two-dimensional Cartesian coordinates x
and y
.
theta = [0 pi/4 pi/2 pi]
theta = 1×4 0 0.7854 1.5708 3.1416
rho = [5 5 10 10]
rho = 1×4 5 5 10 10
[x,y] = pol2cart(theta,rho)
x = 1×4 5.0000 3.5355 0.0000 -10.0000
y = 1×4 0 3.5355 10.0000 0.0000
Cylindrical to Cartesian Coordinates
Open Live Script
Convert the cylindrical coordinates defined by corresponding entries in the matrices theta
, rho
, and z
to three-dimensional Cartesian coordinates x
, y
, and z
.
theta = [0 pi/4 pi/2 pi]'
theta = 4×1 0 0.7854 1.5708 3.1416
rho = [1 3 4 5]'
rho = 4×1 1 3 4 5
z = [7 8 9 10]'
z = 4×1 7 8 9 10
[x,y,z] = pol2cart(theta,rho,z)
x = 4×1 1.0000 2.1213 0.0000 -5.0000
y = 4×1 0 2.1213 4.0000 0.0000
z = 4×1 7 8 9 10
Input Arguments
collapse all
theta
— Angular coordinate
scalar | vector | matrix | multidimensional array
Angular coordinate, specified as a scalar, vector, matrix, or multidimensional array. theta
, rho
, and z
must be the same size, or have sizes that are compatible (for example, theta
is an M
-by-N
matrix, rho
is a scalar, and z
is a scalar or 1
-by-N
row vector). For more information, see Compatible Array Sizes for Basic Operations.
theta
is the counterclockwise angle in the x-y planemeasured in radians from the positive x-axis.
Data Types: single
| double
Complex Number Support: Yes
rho
— Radial coordinate
scalar | vector | matrix | multidimensional array
Radial coordinate, specified as a scalar, vector, matrix, or multidimensional array. theta
, rho
, and z
must be the same size, or have sizes that are compatible.
rho
is the distance from the origin to apoint in the x-y plane.
Data Types: single
| double
Complex Number Support: Yes
z
— Elevation coordinate
scalar | vector | matrix | multidimensional array
Elevation coordinate, specified as a scalar, vector, matrix, or multidimensional array. theta
, rho
, and z
must be the same size, or have sizes that are compatible.
z
is the height above the x-y plane.
Data Types: single
| double
Complex Number Support: Yes
Output Arguments
collapse all
x
, y
, z
— Cartesian coordinates
arrays
Cartesian coordinates, returned as arrays.
Algorithms
The mapping from polar and cylindrical coordinates to Cartesiancoordinates is:
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. Formore information, see Tall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
If you use
pol2cart
with single type and double type operands, the generated code might not produce the same result as MATLAB®. See Binary Element-Wise Operations with Single and Double Operands (MATLAB Coder).
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).
Version History
Introduced before R2006a
See Also
cart2pol | cart2sph | sph2cart
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本 (日本語)
- 한국 (한국어)
Contact your local office