马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
程序编出来了,调试怎么也过不了,希望哪位大虾帮忙调试一下!
u,v,ed,E矩阵需要预定义吗?怎么预定义?
tic;
clear;clc;
epsilon=8.9e-12; num=21; a=0.2/(num-1); t=(num+1)/2;cons=300;
dp1=0.1;pg=1.025;ki=2.2e-4;
v(t,t)=6e4;v1=u;N=0;
while max(max(abs(v-v1)))>cons;
N=N+1;
v1=v;
for i=2:num-1
for j=2:num-1
Eox=-(v(i-1,j)-v(i+1,j))/(2*a);
Eoy=-(v(i,j-1)-v(i,j+1))/(2*a);
E(i,j)=sqrt(Eox.^2+Eoy.^2);
u(i,j)=0.25*(v(i,j-1)+v(i,j+1)+v(i-1,j)+v(i+1,j)+a^2*ed(i,j)/epsilon);
ed(i,j)=-epsilon/(2*a)*(Eox+Eoy)-0.5*((epsilon/a*(Eox+Eoy))^2
+4*(epsilon/a*(Eox*ed(i+1,j)+Eoy*ed(i,j+1))))^0.5;
u(1,:)=0;u(num,:)=0;u(:,num)=0;u(t,t)=6e4;ed(t,t)=3e5;
end;
end;
v=u;
end;
d=[0:0.2/(num-1):0.2];
[x,y]=meshgrid(d);
u=abs(u);ed=abs(ed);E=abs(E);
figure(1);surfl(x,y,abs(u));
figure(2);surfl(x,y,abs(ed));
figure(3);surfl(x,y,abs(E));
toc |