www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/SplineInterpolationOfDistributionAndSpecifyEndpointSlopeExample.m

    %% Spline Interpolation of Distribution and Specify Endpoint Slopes
% This illustrates the use of clamped or complete spline interpolation
% where end slopes are prescribed. Zero slopes at the ends of an
% interpolant to the values of a certain distribution are enforced.

% Copyright 2015 The MathWorks, Inc.

x = -4:4;
y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0];
cs = spline(x,[0 y 0]);
xx = linspace(-4,4,101);
plot(x,y,'o',xx,ppval(cs,xx),'-');