你的for循环都没有end,显然代码都没贴完整,你让我们怎么帮你优化
六重for循环如何优化? 。
2 次查看(过去 30 天)
显示 更早的评论
for ix=1:N+1
x=-1000+(ix-1)*2000/N;
for iy=1:N+1
y=-1000+(iy-1)*2000/N;
Lx(ix,iy)=x;
Ly(ix,iy)=y;
Exx(ix,iy)=0;
Exy(ix,iy)=0;
iip=0;
iiq=0;
for p= -(N-1)/2:(N-1)/2
iip=iip+1;
for q= -(N-1)/2:(N-1)/2
if sqrt(p^2+q^2)>(N-1)/2
continue;
end
iiq=iiq+1;
sitao=asin(2*NA*sqrt(p^2+q^2)/(N-1));
fano=atan2(q,p);
Eopqx(iip,iiq)=0;
Eopqy(iip,iiq)=0;
for m=-(N-1)/2: (N-1)/2
for n=-(N-1)/2: (N-1)/2
if sqrt(m^2+n^2)>(N-1)/2
continue;
end
sitai=asin (2*NA*sqrt(m^2+n^2)/(N-1));
fani=atan2(n,m);
。。。。。。。。。。。。。。。运行速度超级慢,20个数要2个多小时。
0 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!