?? newton_interpol.m
字號:
% Interpolation with Newton polynomials
% Input: x,y: y=f(x)
% xt: where interpolant is evaluated.
% Output: yt=f(xt)
function yt = Newton_interpol(x,y,xt)
n = length(y); if length(x)~=n, error('x and y are not compatible'); end
c=y(:);
for j=2:n
for i=n:-1:j
c(i)=( c(i)-c(i-1) ) / ( x(i) - x(i-j+1) ); % note that x(i)-x(i-1) is not right.
end
end
% Nested evaluation of the polynomial
yt = c(n);
for i= n-1 :-1 :1
yt = yt.*(xt - x(i)) + c(i);
end
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -