马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
程序原文:
global wij;
fid=fopen('data.txt','w');
T=0.1;t0=0;tn=0;
dx=0.01;dy=0.01;dt=0.001;c=2000;
nx=60;ny=60;
u=zeros(nx,ny);un=zeros(nx,ny);
vn=zeros(nx,ny);v=zeros(nx,ny);
u(nx/2,ny/2)=1e-4;
u(nx/2-1,ny/2)=1e-4/2;u(nx/2+1,ny/2)=1e-4/2;
u(nx/2,ny/2-1)=1e-4/2;u(nx/2,ny/2+1)=1e-4/2;
u(nx/2-1,ny/2-1)=1e-4/2;u(nx/2-1,ny/2+1)=1e-4/2;
u(nx/2+1,ny/2-1)=1e-4/2;u(nx/2+1,ny/2+1)=1e-4/2;
%
while(tn<=T)
t0=tn;tn=tn+dt;ts=[t0,tn];
for i=2:(nx-1)
for j=2:(ny-1)
wij=c*c*(u(i+1,j)-2*u(i,j)+u(i-1,j))/(dx*dx)+c*c*(u(i,j+1)-2*u(i,j)+u(i,j-1))/(dy*dy);
w0=[u(i,j),v(i,j)];
[t,w]=ode23('wave',ts,w0);n1=length(t);
un(i,j)=w(n1,1);vn(i,j)=w(n1,2);
end
end
u=un;v=vn;
%
for i=1:nx
for j=1:ny
fprintf(fid,'%.3e\n',u(i,j));
end
end
%
end
surfl(un)
shading interp
colormap(gray);
fclose(fid);
=====================================================================================
我的结果是
jieguo.fig
(68.53 KB, 下载次数: 10)
显然不对,请问是哪里出问题了? |