Interpolation of values between the beginning and end of crank rotation

2 views (last 30 days)
Hi, I am trying to interpolate values during rotation of a crank. I have issue at the transitions from 355-0.5 angle, as the interpolated values in between the (1s-2s) interval decreases, when the cycle should naturally end at 360 degree and new cycle begins with 0. How can I set it up, such that t_tointerpolate at 1.5s = 360 or around and then t_original at 2s = 0.5;
I tried to find the indices of columns where these transitions happen, but no luck.
t_original = [0, 1, 2, 3, 4];
t_tointerpolate = [0.5,1.5, 2.5, 3.5];
angle = [350 , 355, 0.5, 2, 3] ;
for i =1:length(angle)-1
b = find (angle(i+1)<angle(i))
end

Answers (1)

Star Strider
Star Strider on 28 Nov 2017
I would use the interp1 funciton.
Try this:
t_original = [0, 1, 2, 3, 4];
angle = [350 , 355, 0.5, 2, 3];
t_tointerpolate = [0.5,1.5, 2.5, 3.5];
new_angle = interp1(t_original, angle, t_tointerpolate, 'linear', 'extrap');
See the documentation for interp1 for a full description of its abilities.

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!