【正文】
0 0 0 實(shí)驗(yàn)結(jié)果分析: 當(dāng)步長(zhǎng)取的越大時(shí),其值越精確,與精確值產(chǎn)生的誤差就會(huì)越小。附Matlab程序代碼:function u=fwave(nx,hx,nt,ht,lowb,c)% Solves hyperbolic equ39。for i=1:nx+1 x(i)=(i1)*hx。 hib(j)=sin(pi*(1t(j)))+sin(pi*(1+t(j)))。u(2,:)=u(1,:)+initslope*ht。 uexact(j,i)=sin(pi*(x(i)t(j)))+sin(pi*(x(i)+t(j)))。 endendfor j=1:nt+1 for i=1:nx+1 x(i)=(i1)*hx。 u(:,nx+1)=hib。 initslope(i)=0。u=zeros(nt+1,nx+1)。實(shí)驗(yàn)小結(jié): 運(yùn)用適合的差分格式和方法解答波動(dòng)方程混合邊值問題的解,有利于提高解題效率。利用Matlab計(jì)算,在窗口命令中輸入fwave(10,10,0,2),便可得到在該條件下的結(jié)果。數(shù)值格式為:數(shù)值求解流程(圖):輸入時(shí)間步長(zhǎng)、空間步長(zhǎng)、網(wǎng)格數(shù),給邊界條件賦值,利用式()經(jīng)過多次迭代,進(jìn)行計(jì)算。當(dāng)步長(zhǎng)一定時(shí),t的值越大,其分段數(shù)就越大,計(jì)算的值就接近精確值。n, . wave equation.% Example call: u=fwave(nx,hx,nt,ht,init,initslope,lowb,hib,c)% nx, hx are number and size of x panels% nt, ht are number and size of t panels% init is a row vector of nx+1 initial values of the function.% initslope is a row vector of nx+1 initial derivatives of% the function.% lowb is a column vector of nt+1 boundary values at the% low value of x.% hib is a column vector of nt+1 boundary values at hi value of x.% c is a constant in the hyperbolic equation.alpha=c*ht/hx。 init(i)=2*sin(pi*x(i))。endu(:,1)=lowb。for j=2:nt for i=2:nx u(j+1,i)=alpha^2*(u(j,i+1)2*u(j,i)+u(j,i1))+2*u(j,i) ... u(j1,i)。 endend指導(dǎo)教師評(píng)語: 簽字: 年 月 日