Interpolating between end points in polar coordinates

20 vues (au cours des 30 derniers jours)
Eirik Kvernevik
Eirik Kvernevik le 12 Avr 2021
Commenté : Star Strider le 13 Avr 2021
I have an array of polarcoordinate pairs (r,theta), theta given in degrees
13.7807 208.5120
13.9924 225.4886
19.3740 232.1227
14.2353 261.4786
18.4920 282.1455
10.3117 298.3125
19.2983 306.1740
14.7913 326.8975
13.8365 342.4244
I want to interpolate to obtain an array of 360 r-values , one value for each integer degree around the circle.
I have applied the interp1-function to obtain the values:
theta = 1:360;
H = interp1(polarCoords(:,2),polarCoords(:,1),theta);
however I cannot obtain any values between 343 degrees and 208 degrees, H = nan for all angles between 343 and 208.
my questions are :
1 how can I obtain interpolating values between 343 degrees and 208 degrees?
2. I guess the interp1 does an linear interpolation in cartesian coordinates, meaning interpolating by straight lines between the points, if so, how can I interpolate following the curved coordinate line in polar coordinates (linear interpolation in polar coordinates) ?

Réponses (1)

Star Strider
Star Strider le 13 Avr 2021
Try this:
polcords = [13.7807 208.5120
13.9924 225.4886
19.3740 232.1227
14.2353 261.4786
18.4920 282.1455
10.3117 298.3125
19.2983 306.1740
14.7913 326.8975
13.8365 342.4244];
theta_new = linspace(0, 359.9, 360);
r_new = interp1(polcords(:,2), polcords(:,1), theta_new, 'linear', 'extrap');
polcords_new = [r_new(:) theta_new(:)];
figure
polarplot(deg2rad(polcords(:,2)), polcords(:,1), 'pg')
hold on
polarplot(deg2rad(polcords_new(:,2)), polcords_new(:,1), '-r')
hold off
It will do the interpolation (and extrapolation), however since it is simply extrapolating a line, not any sort of pattern, it simply plots a circle for the values it has no data how to to interpolate between. I used 'linear' here because other interpolation or extrapolation methods produced wildly divergent radii.
Experiment to get different results.
  4 commentaires
Eirik Kvernevik
Eirik Kvernevik le 13 Avr 2021
cool, thanks mate !
Star Strider
Star Strider le 13 Avr 2021
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by