lujiangyue 发表于 2006-12-11 14:19

怎样能更好的编写拉格朗日差值多项式程序

谢谢

jackdong 发表于 2006-12-11 16:04

Lagrange 插值多项式

功能:求基于N+1个点的拉格朗日多项式

function =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 coefficientspolynomial

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;
页: [1]
查看完整版本: 怎样能更好的编写拉格朗日差值多项式程序