%ArrayPatGain - This program is an updated and combined version of the programs "ANTGAIN % and "ARRAYPATGAIN" in the 4th edition of Kraus's Electromagnetics. This program % computes and plots the field pattern of a uniform linear array of sources. clear; timesrun=0; while timesrun<1000, if timesrun==0, SP=0.5; PH=0; N=5; MF=1; else, SP=input('Enter element spacing in wavelengths: '); PH=input('Enter phase difference between elements in degrees: '); N=input('Enter number of elements: '); MF=input('Enter pattern multiplication factor: ')'; end; % This version modified to include phase plots % which can be either end referenced or center referenced. % F. Merat 3/29/03 % Compute fields for plotting A=0.01:0.01:6.27; % Angle over 2pi radians PH=-360*SP-180/N; %modified phase for maximum directivity U=(2*pi*SP*cos(A)+(pi*PH/180))/2; % compute argument % Note that /2 is included here rather % than in sine(NU)/sine(U) expression FP=(sin(N*U)./sin(U)); % compute isotropic electric field R=MF.*abs(FP); % multiply as appropriate XI=(180/pi).*((N-1)*U-angle(FP)); % compute phase [end referenced] % the angle(FP) accounts for the sign % of Sine(Nu)/Sine(u) in the phase %XI=(180/pi).*(-angle(FP)); % compute phase [center referenced] % the angle(FP) accounts for the sign % of Sine(Nu)/Sine(u) in the phase pause(0.9); % compute the beam area in theta B=0.01:0.01:3.14; % B is theta -- the angle from 0 degrees % 0