How to draw an polar image under polar coordinate
Show older comments
Hello, I have a problem when drawing a polar image. The problem is like this. I have a matrix A in which a distribution under polar coordinate Z=f(theta,r) is described by its elements Z=f(theta,r)=A(i,j). I want to draw it under polar coordinate like the function image.m for cartesian coordinates.
1 Comment
Stuart Anderson
on 17 Apr 2023
Exactly what I needed. Thanks a lot.
Answers (1)
Walter Roberson
on 17 Jan 2016
N = 150;
maxr = 20;
theta = linspace(0, 2*pi, N+1);
r = linspace(0, maxr, N+1);
theta = theta(1:end-1); %throw away 2*pi since it duplicates 0
r = r(2:end); %throw away 0 since that's at the center
[THETA, R] = ndgrid(theta, r);
Z = f(THETA,R);
[X, Y] = pol2cart(THETA,R);
surf(X, Y, Z);
anything beyond that is drawing the circles and labeling
4 Comments
yangyichun yang
on 17 Jan 2016
Walter Roberson
on 17 Jan 2016
polar.m translates its data to cartesian to do its drawing.
The setup in this code establishes a non-uniform coordinate grid, which surf() is perfectly happy with. surf is not going to place the elements on a rectangular grid: it will put the elements into a circle.
There is no true polar coordinate system in MATLAB. polar.m uses entirely cartesian internally, drawing circles in cartesian coordinates, labeling in cartesian coordinates, transforming the input polar coordinates to cartesian coordinates to draw the lines.
Walter Roberson
on 18 Apr 2023
Note: in the days since I posted the above, Mathworks did add polaraxes that is not in cartesian coordinates at any user-visible level, and added polarplot
But there is still no Mathworks-provided polar image function. There are File Exchange contributions for polar images, and there is the surf work-around that I posted above.
Categories
Find more on Polar Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!