% antarray
%
% Plot of radiation pattern from 3-element array of z-oriented 
% halfwave antennas arranged along the x axis, according to 
% Section 11.4 in the textbook by N. N. Rao.

st =  pi/20;
so =  st.*.5;   
[th,fi]  =  meshgrid (so:st:(pi-so),0:so:(2.*pi));
x  =  sin(th).*cos(fi);
a  =  pi.*x;
r  =  cos(pi.*.5.*cos(th))./sin(th);
r  =  r.*sin(1.5.*a)./sin(0.5.*a);
r  =  r.*r;
x  =  r.*x;
y  =  r.*sin(th).*sin(fi);
z  =  r.*cos(th);
surf (x,y,z);
axis equal;
