Written and maintained by CASRAI Editorial Board
Published · Last updated
On this page
In MATLAB, you work with polar coordinates using three functions: polarplot draws a line plot from an angle theta (in radians) and a radius rho, cart2pol converts Cartesian x, y values to theta and rho, and pol2cart converts them back. The angle is always in radians, measured counterclockwise from the positive x-axis. If your data is in degrees, convert it with deg2rad first.
This guide follows one workflow from start to finish: take Cartesian measurements, convert them with cart2pol, plot them with polarplot, and verify the conversion with a pol2cart round trip. It also covers the three pitfalls that most often produce a wrong-looking polar plot: degrees versus radians, negative radii, and the [-π π] angle range. The function behaviour described here is taken from the MathWorks documentation pages listed under Sources, read on 2026-11-12.
What polar coordinates are used for in research
A polar coordinate pair describes a point by its distance from the origin (rho) and its angle from a reference direction (theta). Data is naturally polar when the quantity of interest depends on direction: antenna and microphone directivity patterns, wind or flow direction against speed, phase and magnitude of a complex response, rotating-machinery measurements, and orientation distributions in imaging. In these cases a polar plot shows the structure directly, where a Cartesian line plot of the same values would hide the circular nature of the angle.
The conversion functions matter just as much as the plot. Many instruments report x and y (or x, y and z), while the analysis question is about radius and angle. cart2pol and pol2cart move between the two without hand-written trigonometry, and the three-output forms carry a third coordinate through unchanged so that cylindrical coordinates work the same way.
How to install or access it
polarplot, cart2pol and pol2cart are part of core MATLAB, published by MathWorks, so no separate toolbox is listed on their reference pages. Access to MATLAB itself, including licence options and the browser-based version, is handled on the MathWorks site at mathworks.com. The authoritative reference for every call below is the MathWorks documentation: polarplot, cart2pol and pol2cart. If you do not have MATLAB, the Free alternatives section below covers GNU Octave and Python’s Matplotlib.
Step-by-step: from Cartesian data to a polar plot and back
The steps use the numeric example from the cart2pol and pol2cart reference pages, so you can check every value against the documentation.
Step 1. Define Cartesian coordinates
- Create the x and y vectors:
x = [5 3.5355 0 -10];y = [0 3.5355 10 0];
Step 2. Convert to polar coordinates with cart2pol
- Call the two-output form:
[theta,rho] = cart2pol(x,y); - Display the results. The
cart2polreference page givesthetaas 0, 0.7854, 1.5708 and 3.1416 (radians) andrhoas 5, 5, 10 and 10. The first point lies on the positive x-axis, the second at 45° (0.7854 rad), the third on the positive y-axis, and the fourth on the negative x-axis.
Step 3. Plot with polarplot
- Plot the converted points:
polarplot(theta,rho) - To show individual points rather than a connecting line, pass a line specification as the third argument, which the documented syntax
polarplot(theta,rho,LineSpec)allows, for examplepolarplot(theta,rho,"o"). - To plot several data sets on one set of axes, use
hold onandhold offaround successive calls. The documentation’s example plotstheta/10andtheta/12overtheta = linspace(0,6*pi)this way, the second with a dashed line ("--").
Step 4. Check the conversion with pol2cart
- Convert back:
[x2,y2] = pol2cart(theta,rho); - Compare with the original. The
pol2cartreference example, which starts fromtheta = [0 pi/4 pi/2 pi]andrho = [5 5 10 10], returnsxas 5.0000, 3.5355, 0.0000 and -10.0000 andyas 0, 3.5355, 10.0000 and 0.0000. The tiny nonzero values that can appear where a true value is zero come from floating-point arithmetic, so compare with a tolerance (for examplemax(abs(x-x2)) < 1e-10) rather than with==.
Plotting a function of the angle directly
When the relationship is already written as rho as a function of theta, skip the conversion and plot it. The polarplot page’s first example is:
theta = 0:0.01:2*pi;rho = sin(2*theta).*cos(2*theta);polarplot(theta,rho)
Note the element-wise multiplication operator .* between the two array terms. The same page shows a spiral, theta = linspace(0,6*pi); polarplot(theta,theta/10). If the angles are in degrees, wrap them: theta = linspace(0,360,50); rho = 0.005*theta/10; polarplot(deg2rad(theta),rho).
The polarplot syntax forms
The documentation lists these call forms. Pick the one that matches the data you hold.
polarplot(theta,rho): angle and radius vectors, theta in radians.polarplot(theta,rho,LineSpec): the same, with a line style, marker and colour specification.polarplot(theta1,rho1,...,thetaN,rhoN): several data sets in one call.polarplot(rho): takes radius values only.polarplot(Z): takes complex values as a single argument.polarplot(tbl,thetavar,rhovar): takes the angle and radius from named table variables.polarplot(pax,___): draws into a specific polar axes object.polarplot(___,Name=Value): adds name-value options such as line width.p = polarplot(___): returns the line object so you can change its properties after plotting.
Output and how to read it
A polar plot places angle around the circle and radius outward from the centre. theta of 0 sits on the right (the positive x-direction) and angles increase counterclockwise, matching the convention cart2pol and pol2cart use, so a point converted with one function appears where you expect on the plot of the other.
The numeric outputs of cart2pol read the same way: theta is the counterclockwise angle from the positive x-axis in radians, and rho is the distance from the origin. Converting radians to degrees for reporting is done with rad2deg(theta), so 0.7854 becomes 45°.
To control what the axes show, the documentation points to thetalim and rlim for the angular and radial limits (for example rlim([-1 1])), and to the properties of the PolarAxes object for further customisation such as tick placement. Limit changes do not alter the data; they only change the visible window. For radial scaling beyond linear axes, compare the approach in the MATLAB log plot guide for Cartesian axes, and see the xlim in MATLAB guide for the Cartesian equivalent of setting limits.
Pitfalls: three reasons a polar plot looks wrong
Degrees passed where radians are expected
The polarplot page states that you should specify theta values in radians. Passing 0 to 360 as if it were radians wraps around the circle many times and produces a dense tangle. Convert with deg2rad, as in the documented example above. Constants such as pi are covered in the MATLAB pi guide.
Negative radii
By default polarplot handles negative rho by mirroring the point through the origin, equivalent to shifting its angle by 180°. A function such as sin(2*theta) that swings negative therefore does not draw an inward loop; it draws the mirrored loop on the opposite side. If you need a different treatment, set the radial limits explicitly with rlim; the documentation example rlim([-1 1]) shows a plot whose radial axis includes negative values.
The [-π π] angle range from cart2pol
The cart2pol page gives the range of theta as -π to π. Points in the lower half-plane therefore come back with negative angles (a point on the negative y-axis returns -π/2, not 3π/2). This is the same convention as the atan2 function; the MATLAB atan2 guide explains how the four-quadrant angle is computed. If you need angles from 0 to 2π, add 2π to the negative values: theta(theta<0) = theta(theta<0) + 2*pi;. This changes the representation, not the point, and pol2cart returns the same x and y either way.
Troubleshooting
- Error from mismatched sizes in
pol2cart. The documentation requirestheta,rhoandzto be the same size or compatible; a scalarrhowith athetaarray is accepted. Checksize(theta)andsize(rho). - Error when passing complex numbers to
pol2cart. The reference page states that complex inputs are no longer accepted as of R2026a. Pass real inputs only, or compute the coordinates directly withx = rho.*cos(theta)andy = rho.*sin(theta), the substitution the page recommends. To plot complex values themselves, use thepolarplot(Z)form. - Plot looks mirrored or rotated. Confirm the angle origin (positive x-axis) and direction (counterclockwise) assumed by your data source. Data recorded as compass bearings does not follow this convention and needs converting before plotting.
- Expected values of exactly zero show as tiny numbers. This is floating-point rounding; use a tolerance when testing equality.
- Function not found.
polarplotand its related functions are documented in current MATLAB releases; check the release you run against the “Introduced in” information on each reference page.
Free alternatives
If you do not have a MATLAB licence, both tools below can draw the same plots. The key difference to watch is the unit used for axis limits, which is a common source of translation errors when moving code between tools.
| Tool | Polar plot call | Angle input | Notes from the documentation |
|---|---|---|---|
| MATLAB | polarplot(theta,rho) |
Radians | Negative rho mirrored through the origin by default; limits via thetalim and rlim. |
| GNU Octave | polar(theta,rho) |
Radians (per the function source) | Accepts a format argument like plot; the documented demo is theta = linspace(0,2*pi,1000); rho = sin(7*theta); polar(theta,rho). |
| Python (Matplotlib) | ax.plot(theta,r) on axes created with subplot_kw={'projection':'polar'} |
Radians data; the demo uses theta = 2*np.pi*r |
Radial controls include set_rmax, set_rticks, set_rmin and set_rorigin; set_thetamin and set_thetamax take limits in degrees. |
Sources for the table: the Octave Forge polar page and the Matplotlib polar demo. For the conversion step in Python, the same arithmetic applies: radius is the square root of x² + y², and the angle comes from the two-argument arctangent, as described in the MATLAB atan2 guide.
The data table below compares the three conversion and plotting functions side by side, with their angle unit and documented range, so you can check inputs and outputs before running a script.
FAQ
How do I plot in polar coordinates in MATLAB?
Use polarplot(theta,rho) with theta in radians and rho as the radius. For example, theta = 0:0.01:2*pi; rho = sin(2*theta).*cos(2*theta); polarplot(theta,rho) is the first example on the MathWorks polarplot page.
How do I convert Cartesian coordinates to polar coordinates in MATLAB?
Use [theta,rho] = cart2pol(x,y). The angle is counterclockwise from the positive x-axis, in radians, in the range -π to π, and rho is the distance from the origin. A third output form, [theta,rho,z] = cart2pol(x,y,z), passes z through unchanged for cylindrical coordinates.
How do I convert polar coordinates to Cartesian coordinates in MATLAB?
Use [x,y] = pol2cart(theta,rho), with theta in radians. Inputs must be real, and since R2026a complex inputs raise an error; compute rho.*cos(theta) and rho.*sin(theta) directly if you have complex values.
Does MATLAB polarplot use degrees or radians?
Radians. To plot degree data, call polarplot(deg2rad(theta),rho).
What happens to negative rho values in polarplot?
By default they are mirrored through the origin, which shifts the point’s angle by 180°.
How do I limit the angle or radius range?
Use thetalim and rlim, for example rlim([-1 1]).
Sources
- MathWorks, polarplot, MATLAB documentation, read 2026-11-12.
- MathWorks, cart2pol, MATLAB documentation, read 2026-11-12.
- MathWorks, pol2cart, MATLAB documentation, read 2026-11-12.
- Octave Forge, polar, read 2026-11-12.
- Matplotlib, Polar plot demo, stable documentation, read 2026-11-12.
Data: MATLAB polar-coordinate functions: inputs, angle conventions and documented ranges
Compares polarplot, cart2pol and pol2cart in MATLAB by input, angle unit, angle reference and documented range or behaviour, compiled from the MathWorks reference pages.
Period covered: 2026.
| Function | Purpose | Angle unit | Angle reference | Documented range or behaviour |
|---|---|---|---|---|
| polarplot | Plot theta and rho on polar axes | radians | Not stated beyond radians input | Negative rho mirrored through the origin by default |
| cart2pol | Cartesian x,y to polar theta,rho | radians | Counterclockwise from positive x-axis | theta in [-pi, pi]; z passed through unchanged |
| pol2cart | Polar theta,rho to Cartesian x,y | radians | Counterclockwise from positive x-axis | Real inputs only; complex inputs error as of R2026a |
Sources
- MathWorks polarplot (accessed 2026-11-12)
- MathWorks cart2pol (accessed 2026-11-12)
- MathWorks pol2cart (accessed 2026-11-12)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







