| 查看: 1753 | 回复: 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 |
» 猜你喜欢
基于基元I统一理论的量子力学本源推导
已经有1人回复
推荐一款可以AI辅助写作的Latex编辑器SmartLatexEditor,超级好用,AI润色,全免费
已经有20人回复
物理学I论文润色/翻译怎么收费?
已经有51人回复
【EI|Scopus 双检索】第六届智能机器人系统国际会议(ISoIRS 2026)
已经有1人回复
2026年第四届电动车与车辆工程国际会议(CEVVE 2026)
已经有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);
回复此楼