Functions > Graphing > Example: Converting Rectangular Coordinates to Polar Coordinates
  
Example: Converting Rectangular Coordinates to Polar Coordinates
Use xy2pol and pol2xy functions to convert rectangular coordinates to polar coordinates and vice versa.
1. Use xy2pol to convert rectangular coordinates to polar coordinates.
Click to copy this expression
In this case, xy2pol parameter is a vector of two elements representing the point coordinates.
2. Use pol2xy to convert the coordinates back to rectangular coordinates.
Click to copy this expression
3. Define a data set representing rectangular coordinates. The first column represents the x-coordinates and the second column represents the y-coordinates.
Click to copy this expression
4. Use xy2pol to convert the coordinates.
Click to copy this expression
Click to copy this expression
In this example, explicit x-coordinate and y-coordinate are used, and not a vector.
Click to copy this expression
The result is a nested vector where each of its elements is a two-element vector representing the polar coordinates.
5. For simplicity, use the submatrix function to convert the nested matrix to a non-nested matrix.
Click to copy this expression
Click to copy this expression
Click to copy this expression
6. Plot the data.
Click to copy this expression
You can convert polar coordinates to rectangular coordinates by explicitly defining the polar coordinates.
Click to copy this expression