%% Design and Analysis Using Antenna Array Designer App
% This example demonstrates how to create and analyze a 6-element linear array of half-wavelength dipoles using Antenna Array Designer app in Antenna Toolbox (TM). The design and analysis are performed at 2.1GHz
%% Open Antenna Array Designer App
% To open the app, at the MATLAB command prompt enter: The command opens a blank canvas.

antennaArrayDesigner

%
%
%% Design Antenna Array
% In the blank canvas, click New. In the ARRAY GALLERY, select Linear Array.
%
% Set the Design Frequency value to 2.1GHz.  Set the Number of Elements to 6.
%
% To analyze this antenna array, click Accept.
%
%% Plot 3-D Pattern
% Observe the array geometry and the dipole's geometry at 2.1GHz in the Array and Layout figure tabs.
% In the toolstrip under the PATTERN section, click 3D Pattern to visualize the pattern for the linear array at the design frequency.
%
% The array has a peak directivity of 11 dBi with maximum beam directed at 90 degree azimuth.
%
%% Plot Azimuth and Elevation Pattern
% In the toolstrip, under the INPUT section click on the Settings (  icon) to change the azimuth and elevation range values. Change the Az Range and El Range to 0:0.5:180. Click Ok.
%
% Under PATTERN section, click on the AZ Pattern and EL Pattern to view azimuth and elevation patterns of the linear array. Observe the azimuth and elevation range.
%
%
%
%% Half-power beamwidth (HPBW) and Sidelobe level (SLL)
% Click on the AZ Pattern tab in the designer. Right click on the polar plot. Select Antenna Metrics from the Measurements tab of the context menu.
%
%
% The half-power beamwidth is 18degree and the sidelobe level is 12.4dB.
%
%
%% Change Maximum Beam Angle
% Phase shift property of the array allows to direct the maximum beam to a specific angle. Steer the beam direction to azimuth 80 degree.
% Antenna Toolbox’s phaseShift method can be used to compute the progressive phase shift required to steer the beam to 80 degrees azimuth.
% The values for phase shift are obtained as below

linArray = design(linearArray('NumElements',6),2.1e9);
ps = phaseShift(linArray,2.1e9,[80 0])';

% In the Property Panel, under Geometry - linearArray change the PhaseShift property to [78.1417 46.8850 15.6283 344.3717 313.1150 281.8583].
% Click Apply. All the analysis gets updated to account for the changes to array configuration. Click on AZ Pattern plot tab to see the maximum beam which is now at 80 degree azimuth.
%
%
%% Coupling Analysis
%% Plot Impedance and S-Parameter
% In the toolstrip under COUPLING section, click Impedance to plot the impedance of each element. Change the edit field Element to plot the impedance of a different element.
% The default reference impedance for S-Parameters plot is 50 Ohms. To change this value, click on Settings under the INPUT section of toolstrip. Change the Ref Impedance(Z0)value to 75 Ohms and click Ok.
%
% Click S-Parameter, under COUPLING section to plot the 6 port S-parameters of the array.
%
%
%% Correlation Analysis
% In the toolstrip, under COUPLING section click on Correlation. In the Element Selection window pop-up, click on 1 and 6 to select element 1 and element of the array.
%
% Click OK.
%
%
%% Embedded Element Analysis
%% Plot 3D, Azimuth and Elevation Pattern
% To visualize the radiation properties of an individual element in the array, click on Embedded Element under PATTERN section of the toolstrip. Click on 3D Pattern. An Element Selection window opens which allows to choose an element from the array.
%
% Select element 3 to visualize its 3D radiation pattern. Click OK. A new figure named Element Pattern is displayed
%
% Click on AZ Pattern, and select the element 5. Similarly, click on EL Pattern and select element 2.
%
%
%
%% Export to MATLAB Workspace
% Click the Export button arrow and then click Export to workspace. In the Export to workspace window, give a name to the array that you've designed. Click on the variable in the workspace to view the properties of the antenna array.
%
%
%% Export to MATLAB Script
% Click the Export button arrow again and then click Export to script to view the linear array and analysis in MATLAB script format. The script has two sections: Array Properties and Array Analysis.
%
% Copyright 2019 The MathWorks, Inc.