Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function p = lagrange_interpolation(x, y)
- n = length(x);
- p = 0;
- for i = 1:n
- L = 1;
- for j = 1:n
- if( i ~= j)
- L = conv(L, [1 -x(j)])/(x(i)-x(j));
- end
- end
- p = p + y(i)*L;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement