How to plot different lagrange interpolation graphs in one figure?

2 ビュー (過去 30 日間)
BOA11
BOA11 2017 年 2 月 19 日
回答済み: Rackelyne Urbino 2019 年 9 月 16 日
How do I plot L_0(x), L_1(x),....,L_4(x) in one figure?
I have gone completely blank on how to do this?
I am letting a=-3,b=3,n=4 and obviously i will be 4 but what do I let x be?
function y = LPoly(a,b,n,i,x)
L=ones(n,n+1);
for j = 1:(n+1) %
x(j) = a + (b-a)*((j-1)/n);
end %
for j=1:(n+1) %
if (i~=j);
L(i,:)=L(i,:).*(x-x(j))/(x(i)-x(j));
end %
end %
end % This is created to end the function.

回答 (1 件)

Rackelyne Urbino
Rackelyne Urbino 2019 年 9 月 16 日
how to plot this problem using Lagrange method?
x| 1, 2, 3, 4
y|1, 2, 0, 3
at x=2.5

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by