登录论坛

查看完整版本 : [讨论]大家看看这到底是怎么回事?


guangying
2008-10-08, 10:47
每次运行下面的这段代码,系统都会提示:下标为非正整数。可我看了半天也没找出来。大家帮忙看看


%Subroutine to apply Mr.Mur's absorbing boundary conditions
function c=mr_mur(ezs,ezs1,ezs2,nx1,ny1,nx,ny,c1,c3)
%corners are done with first order
ezs(1,1)=ezs1(2,1)+c1*(ezs(2,1)-ezs1(1,1));
ezs(1,ny)=ezs1(2,ny)+c1*(ezs(2,ny)-ezs1(1,ny));
ezs(nx,1)=ezs1(nx,1)+c1*(ezs(nx1,1)-ezs1(nx,1));
ezs(nx,ny)=ezs1(nx1,ny)+c1*(ezs(nx1,ny)-ezs1(nx,ny));
%second order elsewhere
for j=2:ny1
ezs(1,j)=ezs2(2,j)+c1*(ezs(2,j)-ezs2(1,j))...
-c3*(hxs(1,j+1)-hxs(1,j-1)+hxs(2,j+1)-hxs(2,j-1));
end
for j=2:ny1
ezs(nx,j)=ezs2(nx1,j)+c1*(ezs(nx1,j)-ezs2(nx,j))...
-c3*(hxs(nx,j+1)+hxs(nx1,j+1)-hxs(nx,j-1)-hxs(nx1,j-1));
end
for i=2:nx1
ezs(i,1)=-ezs2(i,2)+c1*(ezs(i,2)-ezs2(i,1))...
+c3*(hys(i+1,2)+hys(i+1,1)-hys(i-1,2)-hys(i-1,1));
end
for i=2:nx1
ezs(i,ny)=ezs2(i,ny1)+c1*(ezs2(i,ny1)-ezs(i,ny1))...
+c3*(hys(i+1,ny)+hys(i+1,ny1)-hys(i-1,ny)-hys(i-1,ny1));
end
for i=1:nx
for j=1:ny
ezs2(i,j)=ezs1(i,j);
ezs1(i,j)=ezs(i,j);
end
end:confused: :confused:
c=ezs;

其中:ezs(i,j)=ezs1(i,j)=ezs2(i,j) , nx=ny=256, nx1=nx-1 , ny1=ny-1 , c1,c3是常数