フィルターのクリア

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 Center および File ExchangePolynomials についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by