Interpolation of circular data

60 ビュー (過去 30 日間)
Nicolas Bourbaki
Nicolas Bourbaki 2021 年 9 月 1 日
コメント済み: Nicolas Bourbaki 2021 年 9 月 4 日
Hello everybody out there using MATLAB,
Is there a built-in function for interpolating circular data, i.e. a timeseries of angles (in degree) between 0° and 360° to other timepoints.
I've carefully read the documentation for the interp1 function, which doesn't really mention this case, although this post is mentioning it.
This post is mentioning the interpft function, but I'm not sure whether this would help in my case.

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2021 年 9 月 1 日
To my understanding simply extend the input arrays such that you have a couple of points from the first few samples added onto the end adding 2*pi to those angles and a few points from the end of your arrays at the beginning subtracting 2*pi from those:
theta = linspace(0,2*pi-0.001,31);
f = 12*cos(theta) + 5*sin(3*theta).^2;
Theta = [theta(end-3:end)-2*pi,theta,theta(1:3)+2*pi];
F1 = [f(end-3:end),f,f(1:3)];
THETA = linspace(0,2*pi,301);
F2 = 12*cos(THETA) + 5*sin(3*THETA).^2;
Fi = interp1(Theta,F1,THETA,'pchip');
That way you force the interpolation to be periodic, you only need to braket your theta and f array with three (possibly 2 but I'm too lazy to check) points to get the cubic and spline interpolation-methods to give you a periodic interpolation.
HTH
  3 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2021 年 9 月 1 日
Oh, I see, I misunderstood your problem completely. Here's my second attempt at understanding clear plain English...
t = 1:151;
theta = cumsum(rand(size(t))/2);
thetai = unwrap(atan2(interp1(1:51,sin(theta),ti),interp1(1:51,cos(theta),ti)));
This will give you a thetai without the branch-cut at 180,-180 (or 360,0).
HTH
Nicolas Bourbaki
Nicolas Bourbaki 2021 年 9 月 4 日
Thanks, using `unwrap` was what is needed in this case.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by