%% Spline Interpolation with Specified Endpoint Slopes
% Use clamped or complete spline interpolation when endpoint slopes are known. To do this, you can specify the values vector y with two extra elements, one at the beginning and one at the end, to define the endpoint slopes.
%
% Create a vector of data y and another vector with the x-coordinates of the data.

x = -4:4;
y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];

%
% Interpolate the data using spline and plot the results. Specify the second input with two extra values [0 y 0] to signify that the endpoint slopes are both zero. Use ppval to evaluate the spline fit over 101 points in the interpolation interval.

cs = spline(x,[0 y 0]);
xx = linspace(-4,4,101);
plot(x,y,'o',xx,ppval(cs,xx),'-');

% Copyright 2015 The MathWorks, Inc.