trying to create a function for simple Newton polynomial interpolation
Ältere Kommentare anzeigen
I am trying to create a function for simple Newton polynomial interpolation.

This is the recurrance relation I am trying to create on matlab, where the data points (x_i,y_i) are specified by the input vectors x and y, and the points at which I want to evaluate the polynomial at are given by the input vector t. I then want to store the evaluated points in a vector p and display this vector.
I have been inputting two vectors of the same size x and y and then letting the vector t = x so that if everything went right I should get the vector y back out, but I don't and I'm not sure why? Any Help.
nt = length ( t );
%Number of data points
n = length ( x );
%Initial polynomial approximation
p = y(1);
for k = 2:n
%initialise product in the recursive formula
for j = 1:k-1
p = p + (y(k)-p(x(k)))*(t-x(j))/(x(k)-x(j));
end
end
p = p (1:nt);
for l = 1:nt
p(nt) = p(t(nt));
end
display(p);
end
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Polynomials finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!