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.
p = p + (y(k)-p(x(k)))*(t-x(j))/(x(k)-x(j));