263 views (last 30 days)

x = [1 2 3 5 7 8];

y = [3 6 19 99 291 444];

I know I need a polval function like

xx = 1:8;

yy = polyval(xx,n);

I just don't know where to go from there.

Tamir Suliman
on 14 Dec 2016

Check this code though I m not sure

function newton_interpolation(x,y,n,xx)

% x and y are two Row Matrices

% and xx is point of interpolation

% n is the order number which should be less than the matrix size

a(1) = y(1);

for k = 1 : n - 1

d(k, 1) = (y(k+1) - y(k))/(x(k+1) - x(k));

end

for j = 2 : n - 1

for k = 1 : n - j

d(k, j) = (d(k+1, j - 1) - d(k, j - 1))/(x(k+j) - x(k));

end

end

d

for j = 2 : n

a(j) = d(1, j-1);

end

Df(1) = 1;

c(1) = a(1);

for j = 2 : n

Df(j)=(xx - x(j-1)) .* Df(j-1);

c(j) = a(j) .* Df(j);

end

fp=sum(c)

plot(x,y)

title('Newton Interpolation ')

xlabel('x - value')

ylabel('y - value')

axis([min(x)-1 max(x)+1 0 max(y)+50])

grid on

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 6 Comments

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403281

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403281

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403283

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403283

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403284

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403284

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403466

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403466

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403518

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403518

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403528

⋮## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/310196-calculate-f-4-using-newton-s-interpolating-polynomials-of-order-1-through-4-choose-your-base-point#comment_403528

Sign in to comment.