d=30;
N=10;
sintheta=linspace(-0.05,0.05,1001);
delta=pi*d*sintheta/0.5;
pbs=sin(delta);
I=zeros(size(delta));
for i=1:1001
if pbs(i)~=0
I(i)=N^(-2)*(sin(N*delta(i))./sin(delta(i))).^2;
else
I(i)=1;
end
运行后
I=zeros(size(delta))
相当于没有进行for循环,猜想是条件表述有问题,但不知该如何修改