MATLAB: How to generate a spline interpolant that matches the derivative values in MATLAB 7.4 (R2007a)

MATLABslope

I want to constrain the derivative value of the spline at each point. I have a set of X-Y points for this and also the velocity values at each pair and I want to find an interpolating spline that in addition to being differentiable at each point also matches the derivative values with the velocity values that I have.

Best Answer

This can be performed in MATLAB 7.4 (R2007a) using Hermite interpolation which is implemented in the function PWCH. The first few lines of the PWCH help read:
PWCH Piecewise cubic Hermite interpolation
PC = PWCH(X,Y,S) returns the ppform of the piecewise cubic Hermite
interpolant f to the given data values Y and the given slopes S
at the given data sites X. X must be a vector, and S must be of the same
size as Y.
So, for example:
x = 1:10;
y = sin( x );
s = cos( x ); % slopes
xi = linspace( 0, 11, 491 );
pp = pwch( x, y, s )
plot( xi, ppval( pp, xi ), x, y, 'o', xi, pchip( x, y, xi ), '--' )
There is also this similar example in the user guide under Spline Toolbox -> Some Simple Examples -> Knot Choices