马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
function wdot=wave(t,w)
global wij;
wdot=[0.1,wij];
global wij;
fid=fopen('data.txt','w');
T=0.15;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);
============================================================================
报错为
??? Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N)
to change the limit. Be aware that exceeding your available stack space can
crash MATLAB and/or your computer.
Error in ==> D:\MATLAB6p5\toolbox\matlab\funfun\ode23.m
On line 154 ==> [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, args, ...
我只知道是迭代步数超过限制,那么下面那个错是什么???谢谢各位老手帮我看看,这是教材上的程序原文,该不得错哒. |