資源描述:
《《矩陣與數(shù)值分析》實(shí)驗(yàn)報(bào)告.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、《矩陣與數(shù)值分析》實(shí)驗(yàn)報(bào)告學(xué)院:土木市政工程姓名:徐博書學(xué)號(hào):20806075教師:張宏偉班級(jí):2班一、為了逼近飛行中的野鴨的頂部輪廓曲線,已經(jīng)沿著這條曲線選擇了一組點(diǎn)。見下表。1.對(duì)這些數(shù)據(jù)構(gòu)造三次自然樣條插值函數(shù),并畫出得到的三次自然樣條插值曲線;2.對(duì)這些數(shù)據(jù)構(gòu)造Lagrang插值多項(xiàng)式,并畫出得到的Lagrang插值多項(xiàng)式曲線。x0.91.31.92.12.63.03.94.44.75.06.0f(x)1.31.51.852.12.62.72.42.152.052.12.25x7.08.09.210.511.311.612.012.613.013.3f(x)2.32.251.951.
2、40.90.70.60.50.40.25解:1.三次樣條插值函數(shù)程序代碼及運(yùn)行結(jié)果clearall;clc;x=[0.91.31.92.12.63.03.94.44.75.06.07.08.09.210.511.311.612.012.613.013.3];y=[1.31.51.852.12.62.72.42.152.052.12.252.32.251.951.40.90.70.60.50.40.25];n=length(y);h=zeros(1,n-1);fori=1:n-1h(i)=x(i+1)-x(i);endr=zeros(1,n-2);fori=2:n-1r(i)=h(i)/(h(
3、i)+h(i-1));endu=zeros(1,n-2);fori=2:n-1u(i)=h(i-1)/(h(i)+h(i-1));endg=zeros(1,n);g(1)=3*(y(2)-y(1))/h(1);g(n)=3*(y(n)-y(n-1))/h(n-1);fori=2:n-1g(i)=3*(u(i)*(y(i-1)-y(i))/h(i)+r(i)*(y(i)-y(i-1))/h(i-1));endA=zeros(n,n);A(1,1)=2;A(1,2)=1;A(n,n)=2;A(n,n-1)=1;fori=2:n-1forj=1:nifi==jA(i,j)=2;A(i,j-1)=r
4、(i);A(i,j+1)=u(i);endendendm=Ag';fori=1:n-1z=x(i):0.01:x(i+1);s=((h(i)+2.*(z-x(i)))/h(i).^3).*((z-x(i+1)).^2).*y(i)+((h(i)-2.*(z-x(i+1)))/h(i).^3).*((z-x(i)).^2).*y(i+1)+(z-x(i)).*((z-x(i+1)).^2).*m(i)/(h(i).^2)+(z-x(i+1)).*((z-x(i)).^2).*m(i+1)/(h(i).^2);plot(x(i),y(i),'kp',z,s);holdonendgridon;程
5、序運(yùn)行結(jié)果:M=[0.4217,0.6566,-2.6655,2.222,-1.0192,0.5411,0.1305,0.5379,-0.1994,0.2599,-0.0709,0.0238,-0.0243,0.0234,-0.1913,1.8850,-0.8150,0.1235,-0.0199,0.4008,-0.9504];2.Lagrange插值多項(xiàng)式程序代碼及運(yùn)行結(jié)果clearall;clc;x=[0.91.31.92.12.63.03.94.44.75.06.07.08.09.210.511.311.612.012.613.013.3];y=[1.31.51.852.12.62.7
6、2.42.152.052.12.252.32.251.951.40.90.70.60.50.40.25];n=length(y);l=ones(1,n);fori=1:nforj=1:nifi==jl(i)=l(i);elsel(i)=l(i)/(x(i)-x(j));endendendl=l.*y;fori=1:n-1p=zeros();z=x(i):0.01:x(i+1);forj=1:ns=ones();forq=1:nifj~=qs=s.*(z-x(q));endendp=p+l(j).*s;endplot(x(i),y(i),'ko',z,p);holdonendgridon;程序
7、運(yùn)行結(jié)果:二、對(duì)于問題將h=0.025的Euler法,h=0.05的改進(jìn)的Euler法和h=0.1的4階經(jīng)典的Runge-Kutta法在這些方法的公共節(jié)點(diǎn)0.1,0.2,0.3,0.4和0.5處進(jìn)行比較。精確解為:。1.h=0.025的Euler法完整MATLAB程序新建M-文件,建立euler1函數(shù),保存至系統(tǒng)默認(rèn)路徑。function[x,y]=euler1(dyfun,xspan,y0,h)x=xspa