| 查看: 1828 | 回复: 1 | ||
公元19782012木虫 (小有名气)
|
[求助]
一维一阶波动方程的迎风差分
|
|
请各位看看,下面是一维一阶波动方程的迎风差分,MATLAB程序,数值解总是出错。没多少金币,见谅 clear all; clc; %数值解(单边差分迎风格式) a=0; b=1; c=1; T=1; ngrid=[20 501]; xspan=[a b]; tspan=[0 T]; m=ngrid(1); n=ngrid(2); ox=range(xspan)/m; ot=range(tspan)/n; r=c*ot/ox; if r>1 error; end for i=1:m+1 %初始条件 u(i,1)=sin((i-1)*ox); end for j=1:n+1 %边界条件 u(1,j)=sin((j-1)*ot); u(m+1,j)=sin((m)*ox+(j-1)*ot); end for j=1:n %数值解(单边差分迎风格式) for i=2:m u(i,j+1)=(1+r)*u(i,j)-r*u(i-1,j); end end %精确解 for j=1:n+1 %精确解 for i=1:m+1 u1(i,j)=sin((i-1)*ox+(j-1)*ot); end end x=0 x:range(xspan);t=0 t:range(tspan);subplot(2,2,1) plot(x,u(:,n/4),x,u1(:,n/4),'r') title('n=10时刻') grid on subplot(2,2,2) plot(x,u(:,n/2),x,u1(:,n/2),'r') title('n=30时刻') grid on subplot(2,2,3) plot(x,u(:,n*3/4),x,u1(:,n*3/4),'r') title('n=40时刻') grid on subplot(2,2,4) plot(x,u(:,n+1),x,u1(:,n+1),'r') title('n时刻') grid on |
» 猜你喜欢
求助中医院临床中医中标的青年标书学习,谢谢
已经有6人回复
浙大物院表面物理课题组长期招收普博及直博学生
已经有259人回复
物理学I论文润色/翻译怎么收费?
已经有211人回复
【征稿】Springer Nature热电专题 Discover Materials / Discover Chemistry
已经有47人回复
25届硕士申请,材料计算方向
已经有2人回复
课题组招1-2名硕士
已经有1人回复
机时越来越贵之后,我把一部分 DFT 流程搬到了 AI 计算平台上
已经有0人回复
斯坦福大学与Elsevier世界前2%学者新排名查询
已经有1人回复
27申博推荐:南京航空航天大学国际前沿院光学方向招收博士生!
已经有19人回复
华南师范大学+双一流学科物理学+广东省杰青团队2027年博士招生+机器学习驱动材料设计
已经有1人回复
apl投稿状态
已经有2人回复

公元19782012
木虫 (小有名气)
- 应助: 1 (幼儿园)
- 金币: 1664.5
- 散金: 50
- 红花: 1
- 帖子: 267
- 在线: 112.4小时
- 虫号: 3585269
- 注册: 2014-12-09
- 性别: GG
- 专业: 微/纳机械系统

2楼2014-12-28 19:48:16










x:range(xspan);
回复此楼