# Plotting beam pattern of uniform linear array

I am trying to reproduce Fig. 2.17 from the book 'Optimum Array Processing' by Van Trees.

The figure is a polar plot of the beam pattern $$B_{\theta}(\theta)$$ given by

$$B_{\theta}(\theta) = \frac{1}{N}\frac{\sin\left(\frac{N}{2} \frac{2\pi}{\lambda}\, \cos(\theta) \,d\right)}{\sin\left(\frac{1}{2} \frac{2\pi}{\lambda} \,\cos(\theta) \,d\right)}$$

with $$d = \frac{\lambda}{2}$$ and $$N = 11$$ elements. The MATLAB code I have written is as follows:

N = 11; % no. of array elements

th = 0:0.01:2*pi; % theta

B = 1/N*sin(N/2*pi*cos(th))./sin(1/2*pi*cos(th));
BdB = 20*log10(abs(B));

figure
polarplot(th, BdB);
rlim([-40 max(BdB)]);



I am unable to reproduce the figure. I believe there are two reasons:

1. The spacing between elements in th, equal to 0.01, is probably not appropriate. How do we set it?

2. The axis limits on the polar plot, as given in rlim(), should be such that all the lobes converge at the center of the plot. How should we decide these?

You are pretty close, just a few cosmetics will get you there.

1. Your angle resolution isn't quite high enough to hit all the narrow dips in the polar pattern. I increased it to 1000 points.
2. You need to clip the level data at the lower plotting limit (-40dB). Otherwise polarplot() will calculate a negative radius which will poke out on the opposite side of the plot.
3. You can use polaraxes() to flavor your plot to whatever you want.

This looks pretty close to me. It has level ticks at 0 degrees and not a -90 degrees but in my opinion that's easier to read and you can move it with pax.RAxisLocation = -90 if you want. It also has negative angles on the left side, which is (in my opinion) "correct".

%% Polarplot example
N = 11; % no. of array elements

% MOD1: do a finer resoltion and go from -pi to +pi
n = 1000; % number of points
dTheta = 2*pi/n;
th = -pi:dTheta:pi; % theta

B = 1/N*sin(N/2*pi*cos(th))./sin(1/2*pi*cos(th));
BdB = 20*log10(abs(B));
% MOD2: cut off the data at the lowest disaply value.
BdB(BdB<-40) = -40;

figure(1); clf
pax = polaraxes;
polarplot(th, BdB);
rlim([-40 max(BdB)]);
% MOD3: Match angle location and direction.
pax.ThetaZeroLocation = 'top';