欢迎来到天天文库
浏览记录
ID:48588725
大小:537.46 KB
页数:18页
时间:2020-02-26
《lagrange插值分段线性插值matlab代码.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.Lagrange插值:x=0:3;y=[-5,-6,-1,16];n=length(x);symsq;fork=1:nfenmu=1;p=1;forj=1:nif(j~=k)fenmu=fenmu*(x(k)-x(j))p=conv(p,poly(x(j)))endendc(k,:)=p*y(k)/fenmuenda=zeros(1,n);fori=1:nforj=1:na(i)=a(i)+c(j,i)endend输出结果:fenmu=-1p=1-1fenmu=2p=1-32fenmu=-6p=1-611-6c=0.8333-5
2、.00009.1667-5.0000fenmu=1p=10fenmu=教育资料.-1p=1-20fenmu=2p=1-560c=0.8333-5.00009.1667-5.0000-3.000015.0000-18.00000fenmu=2p=10fenmu=2p=1-10fenmu=-2p=1-430c=0.8333-5.00009.1667-5.0000-3.000015.0000-18.000000.5000-2.00001.50000fenmu=3p=10fenmu=6p=1-10fenmu=6p=1-320c=0.833
3、3-5.00009.1667-5.0000-3.000015.0000-18.000000.5000-2.00001.500002.6667-8.00005.33330a=教育资料.0.8333000a=-2.1667000a=-1.6667000a=1000a=1-500a=11000a=1800a=1000a=1.000009.16670a=1.00000-8.83330a=1.00000-7.33330a=1.00000-2.00000a=1.00000-2.0000-5.0000a=1.00000-2.0000-5.000
4、0a=1.00000-2.0000-5.0000a=1.00000-2.0000-5.0000分段线性插值:先保存M文件:x=1:6;y=[7168251224];u=5.3;delta=diff(y)./diff(x);n=length(x);forj=2:(n-1)ifx(j)5、e('position',get(0,'screensize'))axes('position',[0011])[x,y]=ginput;然后在commandwindow里输入以下内容:n=length(x);s=(1:n)';t=(1:.05:n)';u=spline(s,x,t);v=spline(s,y,t);clfresetplot(x,y,'.',u,v,'-');对应的x、y值:0.35729170.25361450.35729170.29096390.35034720.34036140.34618060.4259036、60.34270830.52710840.32534720.61626510.30659720.68734940.2906250.75240960.28923610.79337350.29548610.7969880.32256940.7548193教育资料.0.3406250.68493980.36909720.61506020.38645830.61265060.38993060.72590360.39270830.80662650.39201390.89939760.40243060.92951810.42395830.897、337350.42395830.80783130.42951390.73433730.43159720.64518070.44409720.64397590.45659720.74397590.47048610.84518070.47673610.90542170.49618060.94638550.50868060.8765060.50451390.81867470.50104170.75240960.48923610.64036140.5031250.62951810.50520830.62710840.53229170.708、903610.55104170.7632530.57395830.83554220.59618060.85722890.59479170.78373490.57534720.70903610.55798610.63915660.53576390.5
5、e('position',get(0,'screensize'))axes('position',[0011])[x,y]=ginput;然后在commandwindow里输入以下内容:n=length(x);s=(1:n)';t=(1:.05:n)';u=spline(s,x,t);v=spline(s,y,t);clfresetplot(x,y,'.',u,v,'-');对应的x、y值:0.35729170.25361450.35729170.29096390.35034720.34036140.34618060.425903
6、60.34270830.52710840.32534720.61626510.30659720.68734940.2906250.75240960.28923610.79337350.29548610.7969880.32256940.7548193教育资料.0.3406250.68493980.36909720.61506020.38645830.61265060.38993060.72590360.39270830.80662650.39201390.89939760.40243060.92951810.42395830.89
7、337350.42395830.80783130.42951390.73433730.43159720.64518070.44409720.64397590.45659720.74397590.47048610.84518070.47673610.90542170.49618060.94638550.50868060.8765060.50451390.81867470.50104170.75240960.48923610.64036140.5031250.62951810.50520830.62710840.53229170.70
8、903610.55104170.7632530.57395830.83554220.59618060.85722890.59479170.78373490.57534720.70903610.55798610.63915660.53576390.5
此文档下载收益归作者所有