필터 지우기
필터 지우기

how to approximate a function using Lagrange Interpolation?

조회 수: 3 (최근 30일)
Otto
Otto 2012년 11월 24일
Hi All,
I got an important question. It's desired to approximate the function f(x)=(x+sin(3*x))*(exp((-x^2)/4)) for the interval [-5 5].
It's a task and it's mandatory to approximate this function by Constructing a 25'th degree Lagrange polynomial. Using equally spaced data points is also required. The x-values of the first and last data points must be -5 and 5 respectively.
Here is the code:
That's the lagrange interpolation(I've written it myself):
function y = polyinterp(xNodes,yNodes,x)
n = length(xNodes);
y = zeros(size(x));
for k = 1:25
w = ones(size(x));
for j = [1:k-1 k+1:25]
w = (x-xNodes(j))./(xNodes(k)-xNodes(j)).*w;
end
y = y + w*yNodes(k);
end
and how can I use this code to construct a 25'th degree interpolating polynomial?
I'll appreciate for any help.
Thanks Already!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Polynomials에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by