What is the optimum number of resolution for the conversion from cartesian to polar and vice versa?

1 view (last 30 days)
I am having a very strange issue with interpolation that I cannot seem to debug - I am hoping fresh eyes will help. The problem is best described if I explain it as follows:
I have cartesian data Z(x,y) where x and y are vectors that describe the locations of the values of Z. To get this data onto a polar grid described by (rc, thetac) I just do
[thg,rg] = meshgrid(thetac,rc);
[xn,yn] = pol2cart(thg,rg);
Z = interp2(x,y,Z,xn,yn);
which works fine. I have linearly interpolated from the original cartesian grid to the cartesian version of my polar grid. Great. and I did couple of function on that , followed by converting back from polar to Cartesianas below:
[X,Y]= meshgrid(x,y);
Z2 = griddata(xn,yn,Z,X,Y);
Now, does any one has any idea about the optimum resolution of this system? I mean the relation between (x,y) and (thetac, rc).
  2 Comments
dpb
dpb on 9 Aug 2015
I don't follow what we're supposed to have ideas about??? You initially speak of having some problem you can't debug then ask what seems to be a subjective question...what is the specific problem? Without any data we can't reproduce anything to even begin to look at...
Paul
Paul on 9 Aug 2015
Edited: Walter Roberson on 9 Aug 2015
Thank you for your reply, This is my question:
Is there is any optimum value to select a line space for the (thetac,rc) in polar coordinate in terms of transforming from Cartesian coordinate to the polar coordinate via interpolation, as I have already selected the specific line space for (x,y) in Cartesian coordinate.
Here is my full data :
clc,clear,close all;
h=1;x = -5:0.02:5;y = -5:0.01:5;
[X,Y]= meshgrid(x,y);
Dist =sqrt(X.^2+Y.^2+h^2);
c=100;f=100;w=2*pi*f;k=w/c;A0=1;
t=0;u = (A0)*exp(1i*(w*t-k.*Dist));
Q = (angle(u));
% defining the value of the (r and theta) in a Cartesian, My question is in here, is there any optimum number to select value for the rg and thg line space, or just it should b e select randomly?
thetac = linspace(0,2*pi,101);
rc= linspace(0,9,101); %
[thg,rg] = meshgrid(thetac,rc);
% transforming from polar to the Cartesian
[xn,yn] = pol2cart(thg,rg);
%interpolating from the original Cartesian grid to the Cartesian version of polar grid
Z = interp2(x,y,Q,xn,yn);
%Unwrapping Z
Z1=unwrap(Z,[],1);
[X,Y]= meshgrid(x,y);
Z2 = griddata(xn,yn,Z,X,Y);

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 9 Aug 2015
"optimum" implies there there is a value at which something is at its best and other values are somehow less good. In order to mechanically determine an optimum value, there would have to be a calculation that one could perform that would return some measure of the "goodness" with that value, and then one would have to apply an optimization technique.
In your problem, it could certainly be argued that "no" points would not be an adequate solution, which implies that "more than 0" would be better. However, there is nothing in your description that would allow us to say that "as many as you can hold in memory" would be somehow worse than (say) 20.
There is a rather important problem in Mathematics whose solution is thought to be approximately 10^9608. Mathematicians are not upset about it being that large: mathematicians are upset because no-one knows how to prove that it is that large or to prove what the exact value is. So when you ask for the "optimal" value without describing a penalty against using large values, 10^9608 might be the answer given.
  4 Comments
dpb
dpb on 10 Aug 2015
To add just another point on the idea of "optimum" and interpolation; that will also strongly depend on the shape of the interpolated function--the more nonlinear it is, the finer the resolution required to accurately represent it.
I'd note that starting with a regular grid in cartesian space and transforming to cylindrical coordinates will result in the identical points but the spacing between them will no longer (obviously) be linear. Vice versa in going the other direction; what's uniform in r,theta isn't in x,y. Which is the more appropriate (if either has any advantage) will also be dependent upon the interpolant dependance upon location--if it's got a regular angular component, for example, that might be a more appropriate gridding than cartesian.

Sign in to comment.

Categories

Find more on Scenario Creation and Recording 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!