clear all
N     = 10;
d     = 0.5;
alpha = 2*pi;
dip=[1:N];
kd=2*pi*d;
phi=[0:2*pi/800.1:2*pi];
framemax = 48;
M = moviein(framemax);
set(gcf,'Position',[100 100 640 480])
for n=1:framemax
u=kd*cos(phi)-alpha/framemax*(n-1);
F=abs(sin(N.*u./2+N*1e-15)./sin(u./2+1e-15));
plot(F.*cos(phi),F.*sin(phi),'r','LineWidth',3);
%polar(phi,abs(F));
title([  num2str(N),' elements, '...
        ,num2str(d),' \lambda apart'],'fontsize', 18)
xlabel(['\alpha=' ,num2str(alpha/framemax*(n-1))],'Color','k','fontsize', 18)
hold on
plot(N.*cos(phi),N.*sin(phi),'b','LineWidth',2);
plot(dip-N/2-0.5,dip*0,'o','linewidth',3)
hold off
axis equal
M(:,n) = getframe(gcf);
end
clf reset
set(gcf,'Position',[100 100 800 600])
axis off
movie(M,1,6)
