% Simple program to compute the avarge sidelobes in the planar uniformly
% excited array with size 21x21 elements.
clear; clc;
Nelements=21;
nfftx=5120; nffty=5120;
w_uniform=rectwin(Nelements)*rectwin(Nelements)';
AF_uniform = fftshift(fft2(w_uniform,nfftx,nffty));
AF_uniform_D=AF_uniform;
pattern_uniform=(abs(AF_uniform_D)./max(max(abs(AF_uniform_D))));
sumfield=0; %sum of all radiation pattern
sumoutbeam=0; %sum of radiation pattern out side the main beam
nrfield=0;
nroutbeam=0;
for i=1:nfftx
for j=1:nffty
sumfield=sumfield+pattern_uniform(i,j);
nrfield=nrfield+1;
if pattern_uniform(i,j)