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.
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.
3. Define a data set representing rectangular coordinates. The first column represents the x-coordinates and the second column represents the y-coordinates.
4. Use xy2pol to convert the coordinates.
In this example, explicit x-coordinate and y-coordinate are used, and not a vector.
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.
6. Plot the data.
You can convert polar coordinates to rectangular coordinates by explicitly defining the polar coordinates.