| 查看: 1791 | 回复: 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 |
» 猜你喜欢
如何从铁电相到顺电相。
已经有1人回复
各位大佬,求一份最新Wien2k版本作为学习用途
已经有0人回复
物理学I论文润色/翻译怎么收费?
已经有197人回复
南科大活性流体和软物质课题组诚招2027级博士、硕士研究生和博后
已经有42人回复
瑞典林雪平大学博士后招聘|PEC Water Splitting 方向
已经有24人回复
PRB投稿,Acknowledgment sent to author状态十天了
已经有3人回复
PVA溶解
已经有2人回复
基金申请
已经有44人回复
CSC与新西兰维多利亚大学PhD奖学金项目
已经有0人回复
新西兰Robinson研究所 招聘CSC公派访问人员
已经有0人回复
帮我的英语口语老师找学生
已经有0人回复

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

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










x:range(xspan);
回复此楼
100