Antenna Radiation - Antenna Factor   This code is a MATLAB script designed to visualize the beam pattern of a phased array antenna, specifically focusing on its directional radiation pattern and how it changes with different steering angles. Here's a breakdown of its key components and functionalities: Angular Range Setup: The script starts by creating a vector Psi which spans from −π to π in steps of π/100, with a small offset (0.0001) to avoid division by zero later in the calculations. This range represents the angles (in radians) over which the beam pattern will be evaluated. Parameter Initialization: N is set to 16, indicating the number of elements in the antenna array. However, the description mentions an 8x1 array, which might be a discrepancy unless N is meant to represent something else or the description is generalized. Array Factor Calculation: The script computes the array factor (a_theta_sum) using the formula involving the sine function. This calculation simulates the combined effect of the antenna elements radiating and the phase differences between them, which is critical for steering the beam. The formula used takes into account the number of elements (N) and the angular variable (Psi). Normalization and Logarithmic Conversion: The absolute value of the array factor is normalized to its maximum value to ensure the pattern fits within a standard scale. It's then converted to decibels (dB) to provide a logarithmic scale representation, which is more intuitive for understanding signal strength variations across the pattern. Thresholding: The script applies a threshold of -30 dB to the array factor in decibels. This step is intended to limit the plot's dynamic range, focusing the visualization on more significant parts of the beam pattern (like the main lobe and major sidelobes) by cutting off values below -30 dB. Further Normalization: After thresholding, the script further normalizes the dB values to stretch them across the available plot range, enhancing the visual differentiation of pattern features. Plotting: The script generates several plots to visualize the antenna's beam pattern: A linear scale plot of the normalized absolute array factor versus Psi. A polar plot of the normalized absolute array factor. A decibel scale plot showing the dynamic range and sidelobe levels of the beam pattern. A polar plot in decibels, offering an angular and logarithmic scale representation of the beam pattern.

 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 >   Psi = (-1.0*pi:pi/100:1.0*pi)+0.0001;   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(Psi,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(Psi,a_theta_sum_abs,'-r'); t = findall(gcf,'type','text'); %delete(t);     subplot(2,2,3);plot(Psi,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(Psi,a_theta_sum_abs_dB,'-r');   t = findall(gcf,'type','text');