资源描述:
《抛物型方程差分格式.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验:抛物型方程差分格式(1).cleara=0;b=1;J=10;h=(b-a)/J;T=1;lamda=0.25;taol=lamda*h^2;x=a:h:b;t=0:taol:T;N=length(t);u=zeros(N,J+1);u(1,:)=sin(pi*x);forn=2:Nforj=2:Ju(n,j)=lamda*u(n-1,j+1)+(1-2*lamda)*u(n-1,j)+lamda*u(n-1,j-1);endend[xx,tt]=meshgrid(x,t);zz=exp(-pi^
2、2*tt).*sin(pi*xx);subplot(1,2,1)mesh(xx,tt,zz)subplot(1,2,2)mesh(xx,tt,u)(2).cleara=0;b=1;J=10;h=(b-a)/J;T=1;lamda=8;taol=lamda*h^2;x=a:h:b;t=0:taol:T;N=length(t);u=zeros(N,J+1);u(1,:)=sin(pi*x);S=zeros(J-1,J-1);fori=1:J-1forj=1:J-1ifabs(i-j)==1S(i,j)=1;
3、endendendA=(1+2*lamda)*eye(J-1)-lamda*S;B=inv(A);forn=2:Nu(n,2:J)=(B*(u(n-1,2:J))')';end[xx,tt]=meshgrid(x,t);zz=exp(-pi^2*tt).*sin(pi*xx);subplot(1,2,1)mesh(xx,tt,zz)subplot(1,2,2)mesh(xx,tt,u)(3).cleara=0;b=1;J=10;h=(b-a)/J;T=1;lamda=0.5;taol=lamda*h^2
4、;x=a:h:b;t=0:taol:T;N=length(t);u=zeros(N,J+1);u(1,:)=sin(pi*x);S=zeros(J-1,J-1);fori=1:J-1forj=1:J-1ifabs(i-j)==1S(i,j)=1;endendendA=(1-lamda)*eye(J-1)+0.5*lamda*S;B=(1+lamda)*eye(J-1)-0.5*lamda*S;forn=2:Nu(n,2:J)=(inv(B)*A*(u(n-1,2:J))')';end[xx,tt]=me
5、shgrid(x,t);zz=exp(-pi^2*tt).*sin(pi*xx);subplot(1,2,1)mesh(xx,tt,zz)subplot(1,2,2)mesh(xx,tt,u)