牛顿六次插值MATLAB程序

6次牛顿插值多项式函数% 求取六次Newton插值多项式.

clear;clc;

X = [1 2 3 4 5 6 7];

Y = [0.368 0.135 0.050 0.018 0.007 0.002 0.001];

% 计算1阶均差.

for N1 = 1:length(Y)-1

T1 = N1+1;

F1 = (Y(T1)-Y(N1))/(X(T1)-X(N1));

f1(N1) = F1;

end

disp(f1);

% 计算2阶均差.

for N2 = 1:length(f1)-1

T2 = N2+1;

F2 = (f1(T2)-f1(N2))/(X(N2+2)-X(N2));

f2(N2) = F2;

end

disp(f2);

% 计算3阶均差.

for N3 = 1:length(f2)-1

T3 = N3+1;

F3 = (f2(T3)-f2(N3))/(X(N3+3)-X(N3));

f3(N3) = F3;

end

disp(f3);

% 计算4阶均差.

for N4 = 1:length(f3)-1

T4 = N4+1;

F4 = (f3(T4)-f3(N4))/(X(N4+4)-X(N4));

f4(N4) = F4;

end

disp(f4);

% 计算5阶均差.

F5 = 0;

for N5 = 1:length(f4)-1

T5 = N5+1;

F5 = (f4(T5)-f4(N5))/(X(N5+5)-X(N5));

相关推荐
相关主题
热门推荐