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

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

ID:52593009

大小:361.50 KB

页数:5页

时间:2020-03-28

偏微分差分四种格式的matlab程序.doc_第1页
偏微分差分四种格式的matlab程序.doc_第2页
偏微分差分四种格式的matlab程序.doc_第3页
偏微分差分四种格式的matlab程序.doc_第4页
偏微分差分四种格式的matlab程序.doc_第5页
资源描述:

《偏微分差分四种格式的matlab程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、偏微分差分四种格式的matlab程序(1)Lax-Fridrichs格式functionu=LaxFridrichs(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+1:n+2*m-ku1(i)=-(dt/h)*a*(u0(i+1)-u0(i-1))/2+(u0(i+1)+u0(i-1))/2;endu0=u1;endx=0.01:0.01:n/100;u=u1

2、((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-Fridrichs')formatshort;functionux=U(x)formatlong;ifx<=0ux=1;elseux=0;end>>u=LaxFridrichs(1,0.005,101,0,1,100)运行结果(2)迎风格式functionu=Yingfeng(a,dt,n,x1,x2,m)forma

3、tlong;h=(x2-x1)/(n-1);ifa>0forj=1:(n+m)u0(j)=U(x1+(j-m-1)*h);endelseforj=1:(n+m)u0(j)=U(x1+(j-1)*h);endendu1=u0;fork=1:mifa>0fori=(k+1):n+mu1(i)=u0(i)-(dt/h)*a*(u0(i)-u0(i-1));endelsefori=1:n+m-ku1(i)=u0(i)-(dt/h)*a*(u0(i+1)-u0(i));endendu0=u1;endx=0.01:0.01:n

4、/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')formatshort;title('迎风格式')functionux=U(x)formatlong;ifx<=0ux=1;elseux=0;end>>u=Yingfeng(1,0.005,101,0,1,100)运行结果(3)Lax-Wendroff格式functionu=LaxWendroff(a,dt,n,x1,x

5、2,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+1:n+2*m-ku1(i)=u0(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]

6、);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*

7、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(

8、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)运行结果

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。