Lagrange polynomial giving me Inf in final form

2 ビュー (過去 30 日間)
Steve Avilesmejia
Steve Avilesmejia 2020 年 10 月 30 日
回答済み: KSSV 2020 年 10 月 30 日
Can this be resolved?
  5 件のコメント
Steve Avilesmejia
Steve Avilesmejia 2020 年 10 月 30 日
im just not sure why it is coming out as an "Inf".
Steve Avilesmejia
Steve Avilesmejia 2020 年 10 月 30 日
In this case does this code not work or is there a way around it?

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2020 年 10 月 30 日
% clc; clear all ;
sp = [30 45 60 75 90 120];
mb = [2 4 9 17 27 82];
n=length(sp)-3;
syms x;
Q = 0;
for i = 1:n+1
M = 1;
for j = 1: n+1
if j~=i
M = M * (x - sp(j))/(sp(i)-sp(j));
end
end
Q = Q + mb(i)*M;
end

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by