三次样条插值法程序的哪位大虾帮忙写下阿

来源:百度知道 编辑:UC知道 时间:2024/06/30 14:00:51
用java和C和C++都可以阿

按照你学过的数学推导公式,把它翻译成程序语言就可以了
如果用C写,看着好象是一个三阶样条插值程序,其实这其中要写很多的函数,有点麻烦,还是你自己写吧.

1.你得告诉人家用什么语言写
2.你的分有点少了
所以我就随便给你一段代码,是用MATLAB做的三阶样条插值程序:
function yhat = splintFE(x,y,xhat,fp1,fpn)
%splintFE Cubic-spline interpolation with fixed slope end conditions
%
%Synopsis: splintFE(x,y,xhat,fp1,fpn)
%
%Input: x,y = vectors of discrete x and y = f(x) values
% xhat = (scalar or vector) x values where interpolant is evaluated
% fp1 = slope at x(1), i,e.,fp1 = f'(x(1))
% fp1 = slope at x(n), i,e.,fp1 = f'(x(n));
%
%output yhat = (vector or scalar) value(s) of the cubic spline interpolant
% evaluated at xhat. size(yhat) = size(xhat)

%--- Set up system of equations for b(1)
x = x(:); y = y(:); xhat = xhat(:); %convert to columu vectors
n = length(x);
dx = diff(x); % vector of x(i+1) - x(i) values
divdif = diff(y)./dx; % vector of divided differences, f[x(i),x(i+1)]