|
Lagrange 插值多项式
功能:求基于N+1个点的拉格朗日多项式
function [C,L]=lagran(X,Y)
% input - X is a vector that contains a list of abscissas
% - Y is a vector that contains a list of ordinates
% output - C is a matrix that contains the coefficients of the lagrange interpolatory polynomial
- L is a matrix that contains the lagrange coefficients polynomial
w=length(X);
n=w-1;
L=zeros(w,w);
for k=1:n+1
V=1;
for j=1:n+1
if k~=j
V=conv(V,poly(X(j)))/(X(k)-X(j));
end
end
L(k,:)=V;
end
C=Y*L; |
|