23 lines
425 B
Matlab
23 lines
425 B
Matlab
function[p] = newton_interpol(x,x_i,y_i,n)
|
|
|
|
% Programm berechnet den Wert des Newtonschen Interpolationspolynoms p
|
|
% zu den n+1 Stuetzstellen (x_i(i), y_i(i)) i=1:n+1 an der Stelle x
|
|
|
|
|
|
% Berechne gammas:
|
|
|
|
gamma = gammas(x_i,y_i,n);
|
|
|
|
% Bereche den Wert des Interpolationsploynoms p an der Stelle x:
|
|
p=gamma(1);
|
|
|
|
for i=2:n+1
|
|
p_i=gamma(i);
|
|
for j=1:i-1
|
|
p_i=p_i.*(x-x_i(j));
|
|
end
|
|
p=p+p_i;
|
|
p_i=0;
|
|
end
|
|
|