clear
N=51;U=25;%51
fi=0:pi/1000:2*pi;
n=(0:N-1)';h=25;
dl=.5;% distancia entre elementos, en long. de onda
A=ones(N,1);
%A=chebwin(N,U);
for k=40:180
%A=circshift(A,k);%A=ones(N,1);%b=besselj(-4:4,4);A=A./(j.^(-4:4)')./b';%%alf=5*cos(ones(N,1)*fi-2*pi*n/N*ones(1,length(fi)));A=besseli(0,2.222*sqrt(1-((n-h)/h).^2));
alf=n*2*pi*dl*cos(fi-0*pi/180);
W=exp(j*n*2*pi*dl*cos(k*pi/180));
ec=sum((W.*A*ones(1,length(fi))).*exp(j*alf));
e=abs(ec);en=e/max(e);
plot(180/pi*fi,20*log10(en)),grid on,axis([0 180 -40 0])
set(findobj('Type','line'),'LineWidth',1.5);
pause(.1),
end

r=0*exp(-j*n'*2*pi*dl*cos(60*pi/180))+sqrt(2)*exp(-j*n'*2*pi*dl*cos(80*pi/180));
Wo=exp(j*n*2*pi*dl*cos(fi)).*(A*ones(1,length(fi)));
eo=r*Wo;eo=abs(eo);en=eo/max(eo);
plot(180/pi*fi,20*log10(en)),grid on,axis([10 180 -40 0])
set(findobj('Type','line'),'LineWidth',1.5)