全文预览

偏微分差分四种格式的matlab程序

上传者:读书之乐 |  格式:doc  |  页数:5 |  大小:347KB

文档介绍
i)-(dt/h)*a*(u0(i+1)-u0(i-1))/2+(dt/h)^2*a*a*(u0(i+1)-2*u0(i)+u0(i-1))/2;endu0=u1;endx=0.01:0.01:n/100;u=u1((m+1):(m+n));plot(x,u,'r');axis([01-0.51.5]);holdony=1.*(x<=0.5)+0.*(x>0.5);plot(x,y,'c')title('Lax-Wendroff')formatshortfunctionux=U(x)formatlong;ifx<=0ux=1;elseux=0;end>>u=LaxWendroff(1,0.005,101,0,1,100)运行结果(4)Beam-Warming格式functionu=BeamWarming(a,dt,n,x1,x2,m)formatlong;h=(x2-x1)/(n-1);forj=1:(n+2*m)u0(j)=U(x1+(j-m-1)*h);endu1=u0;fork=1:mfori=k+2:n+2*m-ku1(i)=u0(i)-a*(dt/h)*(u0(i)-u0(i-1))-a*(dt/h)*(1-a*(dt/h))*(u0(i)-2*u0(i-1)+u0(i-2))/2;endu0=u1;endx=0.01:0.01:n/100;u=u1((m+1):(m+n));plot(x,u,'r');axis([01-0.51.5]);holdony=1.*(x<=0.5)+0.*(x>0.5);plot(x,y,'c')title('Beam-Warming')formatshortfunctionux=U(x)formatlong;ifx<=0ux=1;elseux=0;end>>u=BeamWarming(1,0.005,101,0,1,100)运行结果

收藏

分享

举报
下载此文档