How to draw an polar image under polar coordinate
Mostra commenti meno recenti
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 Commento
Stuart Anderson
il 17 Apr 2023
Exactly what I needed. Thanks a lot.
Risposte (1)
Walter Roberson
il 17 Gen 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 Commenti
yangyichun yang
il 17 Gen 2016
Walter Roberson
il 17 Gen 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
il 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.
Categorie
Scopri di più su Polar Plots in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!