%% Visualize CDL Channel Model Characteristics
% This example shows how to visualize CDL channel characteristics and explore channel information about the antenna element, element pattern, and cluster paths.
% Define the channel configuration structure by using an nrCDLChannel System object. Specify the delay profile as CDL-D.

cdl = nrCDLChannel;
cdl.DelayProfile = 'CDL-D';

% Configure the transmit array size as a vector of the form \left\lbrack M\;N\;P\;M_{\mathrm{g}\;} N_{\mathrm{g}} \right\rbrack =\left\lbrack 4\;3\;2\;1\;2\right\rbrack, which specifies two rectangular panels (M_{\mathrm{g}} =1and N_{\mathrm{g}} =2) of a 4-by-3 antenna array (M=4 and N=3) and two polarizations (P=2). The total number of polarized elements in the array is M\times N\times P\times M_{\mathrm{g}} \times N_{\mathrm{g}} =48.

txSize = [4 3 2 1 2];
cdl.TransmitAntennaArray.Size = txSize;

% Configure the vertical and horizontal element spacing and the vertical and horizontal panel spacing, in wavelength, as a vector of the form \left\lbrack \lambda_{\mathrm{v}} \;\lambda_{\mathrm{h}} \;{\textrm{dg}}_{\mathrm{v}} \;{\textrm{dg}}_{\mathrm{h}} \right\rbrack. Because panel spacing is measured from the center of the panels, to avoid panel overlapping, set {\textrm{dg}}_{\mathrm{h}} to a value greater than 1 wavelength. To ensure uniform antenna element spacing across vertically and horizontally separated panels, configure panel spacings as {\textrm{dg}}_{\mathrm{v}} =\;\lambda_{\mathrm{v}} \times M and {\textrm{dg}}_{\mathrm{h}} =\lambda_{\mathrm{h}} \times N, respectively.

lambda_v = 0.5;
lambda_h = 0.5;
dg_v = lambda_v*txSize(1); % lambda_v * M
dg_h = lambda_h*txSize(2); % lambda_h * N
cdl.TransmitAntennaArray.ElementSpacing = [lambda_v lambda_h dg_v dg_h];

% Configure the mechanical orientation of the array as \left\lbrack \alpha \;\beta \;\gamma {\left.\right\rbrack }^T ={\left\lbrack 0\;15\;0\right\rbrack }^T \right., which specifies 0 degrees bearing, 15 degrees downtilt, and 0 degrees slant.

cdl.TransmitAntennaArray.Orientation = [0 15 0]';

% For an overview of all transmit antenna array properties, see the TransmitAntennaArray property of the nrCDLChannel System object.
% Display the channel characteristics at the transmitter end.

figTx = displayChannel(cdl,'LinkEnd','Tx');

% The generated figure supports customized data tips. Add data tips in the current figure by enabling the data cursor mode.

datacursormode on;

% With data cursor mode enabled, explore channel characteristics by adding data tips. To create a data tip, click a data point. To create multiple data tips, press the Shift key while clicking the data points.
% For example, this figure shows data tips added to the antenna element, element pattern, and cluster paths at the transmitter end.
% Antenna element data tips include information about the position, polarization angle, and element number of each antenna element. The element numbers indicate the order in which the channel model maps input signals column-wise to antenna elements. For more details, see the TransmitAntennaArray.size property of the nrCDLChannel System object.
% Element pattern data tips include the directivity corresponding to any azimuth and zenith angles.
% Cluster path data tips include the average path gain and azimuth and zenith angles of the cluster path.
%
% Visualize and explore channel characteristics at the receiver end. To customize the receive antenna array, use the ReceiveAntennaArray property of the nrCDLChannel System object. Then, display the channel characteristics at the receiver end by calling the displayChannel function with the 'LinkEnd','Rx' name-value pair argument.

figRx = displayChannel(cdl,'LinkEnd','Rx');

% Explore channel information about the antenna element, element pattern, and cluster paths at the receiver end by enabling data cursor mode for the current figure.

datacursormode on;

% Copyright 2020 The MathWorks, Inc.