Antenna Radiation - Antenna Factor   The MATLAB is designed to visualize the directional radiation pattern, specifically the array factor, of a phased array antenna system in various ways, including linear and polar plots both in absolute terms and in decibels (dB). Let's break down the key components and functionalities of this code: Angular Range Setup: The script defines a vector theta which ranges from −π to π with a small offset (0.0001) to avoid division by zero in subsequent calculations. This range covers the full 360 degrees around the antenna, allowing for a complete analysis of its radiation pattern. Wave Number and Element Spacing: It initializes k as 1, which typically represents the wave number (related to the wavelength of the signal) and d as 2, presumably the distance between elements in the antenna array (though the units are not specified, it's often in terms of wavelength). Calculation of Psi: The variable Psi is calculated as k*d*cos(theta), representing the phase difference between elements in the array as a function of the observation angle theta. This phase difference is crucial for beamforming, allowing the antenna array to direct its beam in specific directions. Array Factor Calculation: The script computes the array factor a_theta_sum using a formula that simulates the combined effect of the individual antenna elements. This factor is a function of the number of elements N (16 in this case) and the phase difference Psi, capturing how the beam's strength varies with angle. Normalization and dB Conversion: After computing the array factor, the script normalizes its absolute value to the maximum value observed, ensuring that the pattern fits within a standard scale. It then converts these normalized values into decibels to provide a logarithmic scale representation, which helps in visualizing the differences in beam strength across different angles. Thresholding at -30 dB: To focus on the most significant parts of the beam pattern, any value below -30 dB is set to -30 dB. This step helps in visualizing the main lobe and significant side lobes by de-emphasizing the weaker parts of the pattern. Further Normalization: The script performs an additional normalization step on the dB values to stretch them across the available plot range, enhancing the visualization of the pattern's features. Plotting: The script generates a series of plots to illustrate the antenna's beam pattern: A linear scale plot of the normalized absolute array factor versus theta, showing the shape of the beam. A polar plot of the normalized absolute array factor, providing an angular representation of the beam pattern. A plot of the array factor in decibels, emphasizing the dynamic range and sidelobe levels. A polar plot in decibels, combining the benefits of a logarithmic scale with an angular perspective.

 Followings are the code that I wrote in Octave to creates all the plots shown in this page. You may copy these code and play with these codes. Change variables and try yourself until you get your own intuitive understanding.   < Code 1 >   theta = (-1.0*pi:pi/100:1.0*pi)+0.0001;   k = 1; d = 2;   Psi = k*d*cos(theta);   N = 16;           a_theta_sum = sin(N .* Psi ./ 2) ./ (N .* sin(Psi ./ 2));   a_theta_sum_abs = abs(a_theta_sum); a_theta_sum_abs = a_theta_sum_abs ./ max(a_theta_sum_abs); a_theta_sum_abs_dB = 10 .* log(a_theta_sum_abs);   for i = 1:length(a_theta_sum_abs_dB)     if a_theta_sum_abs_dB(i) <= -30         a_theta_sum_abs_dB(i) = -30;     end;     end;           a_theta_sum_abs_dB = a_theta_sum_abs_dB - min(a_theta_sum_abs_dB); a_theta_sum_abs_dB = a_theta_sum_abs_dB/max(a_theta_sum_abs_dB);   hFig = figure(1,'Position',[300 300 700 600]);   subplot(2,2,1); plot(theta,a_theta_sum_abs); xlim([-pi pi]); tStr = sprintf("N = %d",N); title(tStr);   set(gca,'xtick',[-pi -(3/4)*pi  -pi/2 -pi/4 0 pi/4 pi/2 (3/4)*pi pi]); set(gca,'xticklabel',{'-pi','-3pi/4','-pi/2' '-pi/4' '0' 'pi/4' 'pi/2','-3pi/4','pi'});   subplot(2,2,2); polar(theta,a_theta_sum_abs,'-r'); t = findall(gcf,'type','text'); %delete(t);     subplot(2,2,3);plot(theta,10 .* log(a_theta_sum_abs));ylim([-30 1]); xlim([-pi pi]); tStr = sprintf("N = %d",N); title(tStr);   set(gca,'xtick',[-pi -(3/4)*pi  -pi/2 -pi/4 0 pi/4 pi/2 (3/4)*pi pi]); set(gca,'xticklabel',{'-pi','-3pi/4','-pi/2' '-pi/4' '0' 'pi/4' 'pi/2','-3pi/4','pi'});   subplot(2,2,4); polar(theta,a_theta_sum_abs_dB,'-r');   t = findall(gcf,'type','text');