作业帮 > 综合 > 作业

利用matlab实现Lagrange 插值多项式

来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/05/10 13:06:21
利用matlab实现Lagrange 插值多项式
主程序为:
function SF_Sin
x = -5 : 0.01 : 5;
y = sin(x);
plot(x,y,'r:') % 绘制准确函数图像
hold on
px = -5 : 1 : 5; % 插值点
py = sin(px); % 插值点上的函数值
plot(px,py,'m+') % 绘制插值点
[Ln] = SF_Lagrange(px,py); % 根据插值点及其值计算 Lagrange 插值多项式
Lx = -5:0.01:5; % 绘图点
Ly = polyval(Ln,Lx); % 计算绘图点上的多项式函数值
plot(Lx,Ly,'b-.') % 绘制 多项式 图像legend('sin(x)','point','Ln','Location','NorthEast')
hold off
求其中的函数[Ln] = SF_Lagrange(px,py);代码
就是因为没有定义[Ln] = SF_Lagrange(px,py)所以不能运行啊。。。
利用matlab实现Lagrange 插值多项式
我看看我有没有,好像我有一个拉格朗日插值法的程序
function h = hlagr2(L,x)
% HLAGR2
% MATLAB m-file for fractional delay approximation
%拉格朗日插值法的实现函数
% by LAGRANGE INTERPOLATION method
% h = hlagr2(L,x) returns a length L (real) FIR
% filter which approximates the fractional delay
% of x samples.
% Input: L = filter length (filter order N = L-1)
% x = fractional delay (0 < x