You are on page 1of 1

function p=lagrange(x,y)

n=lenght(X);
s=0;
for i=1:n
L=1;
for j=1:n
if j~=i
L=conv(L, [1 -x(j)])/(x(i)-x(j));
end
end
s=s+y(i)*L;
p=s;
end

You might also like