1

I have a series of values and times in an array. I want to create a spline fit wherein the derivative at every point that I give it is at zero. In short, I want to form a complex sinusoidal-looking wave from it. Each value should end up being either a local minimum or a local maximum. in the output. When I interpolate with the interp1 'spline' function, the first derivative at each given point is not zero. In reference to the code below, slopes1 should ideally equal to zero for t = [1 2 3 4 5 6 7 8 9 10]. I hope that this makes sense. If this is not possible with splines, then what would be the best approach to generate an oscillating curve with a series of minimums and maximums that are continuously 1st and 2nd order differentiable?

t=[1 2 3 4 5 6 7 8 9 10];
y=[1,-2,2,-1,6,-5,1,-1,8,-5];
pp = interp1(t,y,'spline','pp');
slopes1=ppval(pp_der,t);
SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
  • Possibly related: https://stackoverflow.com/q/53517842/8239061 – SecretAgentMan Feb 15 '19 at 03:24
  • Not much to do here, right? If you want third order passing through p0 and p1 with slope 0 at both, this already defines all 4 parameters of a 3rd order function. – mikuszefski Feb 15 '19 at 07:08
  • 1
    You could look into a `pchip' interpolation. I don't think the derivatives at your points will necessarily be zero, but it should perform better than a spline as it does not enforce anything for the second derivatives. – RPM Feb 15 '19 at 09:52

0 Answers0