Interpolation of circular data

조회 수: 65 (최근 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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by