필터 지우기
필터 지우기

Lagrange polynomial giving me Inf in final form

조회 수: 1 (최근 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 CenterFile Exchange에서 Conversion Between Symbolic and Numeric에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by