% Direction of arrival demonstration
% Assume the signal has been mixed to baseband and
% synchronously sampled on each antenna.

% Variables
F0 = 1e8; % Carrier frequency, 100 MHz
c = 3e8; % Speed of light
lam0 = c/F0; % Wavelength
d = lam0/2; % Quarter wavelength antenna spacing
th0 = 0*pi/180; % Angle of arrival
L = 15; % Number of antennas
f0 = d*sin(th0)/lam0;

% Create signal
x = exp(1j*2*pi*f0*[0:L-1]);

% Analyze signal
NFFT = 1024; % FFT size
X = fftshift(fft(x,NFFT)); % Zero padded FFT

% Visualize signal
th = asin(lam0*([0:NFFT-1]/NFFT - 0.5)/d); % Frequency to angle
polarplot(th,abs(X));
