Conversion of Polar Data to Cartesian Data

31 次查看(过去 30 天)
Good Morning,
I have an interpolation problem that I thought others would have more insight on. I have cartesian data Z(x,y) where x and y are vectors that describe the locations of the values of Z in terms of Cartesian coordinates. My goal is to take this data and to project it upon a polar grid so that I can perform an azimuthal average of the data.
To get the data Z(x,y) onto a polar grid, I essentially use the griddata function:
load('Zdata.mat')
[X,Y]=meshgrid(x,y);
[TH0,R0]=cart2pol(X,Y);
vor_polar=griddata(X,Y,vor,TH0,R0);
subplot(2,2,[1 3]); contourf(X/1000,Y/1000,vor); axis([-100 100 -100 100]);
subplot(2,2,[2 4]); contourf(R0/1000,TH0,vor_polar); axis([0 100 -3 3]);
This procedure works fine if Z(x,y) has ideal circular symmetry, such as shown in Figure 1. However, when I begin to add asymmetries to Z(x,y) (i.e. perturbations which drives the data away from circular symmetry) as in Figure 2, the interpolation scheme doesn't seem to pick up these asymmetries. I wanted to know if there are any underlying problems with my procedure or if this is related to the griddata function.

回答(1 个)

David Ding
David Ding 2017-5-26
Hi Gabe,
The function "cart2pol" already converts the coordinates from Cartesian to polar. At each (r0, th0) point, the value of "vor" should be the same as "vor_polar" as there is a one-to-one mapping between the Cartesian coordinate and the polar coordinate. Therefore, you do not need to use "griddata".
In any case, "griddata" function's fourth and fifth argument accepts only Cartesian coordinates. When you input polar coordinates, certain points have value "NaN", which results in the interpolated points not picking up the asymmetries.
[TH0,R0]=cart2pol(X,Y);
contourf(R0/1000,TH0,vor);
is suffice to map the data "vor" onto polar coordinates.
Thanks,
David

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by