Interpolation of circular data

62 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by