Langrange interpolation Code
function [ ] = Langrange( )
x=[1,2];
y=[1,2];
a=9;
n=length(x)
L=ones(n,size(a,2))
for i=1:n
for j=1:n
if (i~=j)
L(i,:)=L(i,:).*(a- x(j))/( x(i)- x(j))
end
end
end
o=0;
for i=1:n
o=o+y(i)*L(i,:)
end
end
x=[1,2];
y=[1,2];
a=9;
n=length(x)
L=ones(n,size(a,2))
for i=1:n
for j=1:n
if (i~=j)
L(i,:)=L(i,:).*(a- x(j))/( x(i)- x(j))
end
end
end
o=0;
for i=1:n
o=o+y(i)*L(i,:)
end
end
Comments
Post a Comment