Interpolation of circular data
조회 수: 65 (최근 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.
David Long (2021). Interpolate angles (https://www.mathworks.com/matlabcentral/fileexchange/65289-interpolate-angles), MATLAB Central File Exchange. Retrieved September 1, 2021. is showing a way using the unwrap function, which I don't quite understand.
댓글 수: 0
채택된 답변
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
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
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!