# Interpolating between end points in polar coordinates

49 ビュー (過去 30 日間)
Eirik Kvernevik 2021 年 4 月 12 日
コメント済み: Star Strider 2021 年 4 月 13 日
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) ?

サインインしてコメントする。

### 回答 (1 件)

Star Strider 2021 年 4 月 13 日
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
hold on
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 件のコメント表示非表示 3 件の古いコメント
Star Strider 2021 年 4 月 13 日
My pleasure!
.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by