声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1014|回复: 1

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

[复制链接]
发表于 2006-12-11 14:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
谢谢
回复
分享到:

使用道具 举报

发表于 2006-12-11 16:04 | 显示全部楼层
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;
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-7 02:28 , Processed in 0.061938 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表