Matlab 三次样条插值(有条件)

来源:百度知道 编辑:UC知道 时间:2024/05/14 20:03:49
x=[0 1 2 3 4 5 6 7 8 9 10];
y=[0.0 0.79 1.53 2.19 2.71 3.03 3.27 2.89 3.06 3.19 3.29];
在x=0处y的二阶导数为0.8,在x=10处y的二阶导数为0.2,请问应该怎样进行三次样条插值??

这个代码改一下:

function [yi,yxi,yxxi] = csinterp( x, y, xi )

% CSINTERP 1-D piecewise cubic spline interpolation of tabulated
% data and calculation of first and second derivatives.
% [YI,YXI,YXXI] = CSINTERP(X,Y,XI) interpolates function values,
% first and second derivatives using the rows/columns (X,Y) at
% the nodes specified in XI. X and Y should be row or column
% vectors, each containing at least three values, otherwise the
% function will return an empty output.
% The vector X specifies the points at which the data Y is given.
% Output data YI, YXI and YXXI are same size as XI.
% X and XI can be non-uniformly spaced, but repeated values in X
% will be removed and the resulting vector will be sorted.
% This function also extrapolates the input data (no NaNs are
% returned); use extrapolated values at your own risk.
%
% Requires bindex.m (