%% Link Budget Analysis
% In the design of wireless communications links between two sites, issues
% of range, throughput, and received signal quality are of critical
% importance to the system engineer. Link budget analysis accounts for all
% gains and losses in the communication link. Some factors and design
% choices, such as propagation path length, signal polarization, and
% antenna feed cable, degrade signal quality, while others, such as the
% power amplifier and antenna size, can increase transmitted signal strength.
% 
% This example uses <matlab:linkBudgetAnalyzer linkBudgetAnalyzer> app to
% tabulate system parameters and compute gains and losses that impact
% system performance. Separate tabs specify settings for *Uplink* and
% *Downlink*. After specifying the uplink and downlink settings, select
% *Analyze* to update the gains and losses reported in the *Results* tab
% and the tabs with plots of free space path loss (FSPL) and G/T for uplink
% and downlink.
%
% <<LinkBudgetAnalyzerDefault.png>>
%

% Copyright 2018-2021 The MathWorks, Inc.

%% Settings
% The *Uplink* and *Downlink* tabs contain these collapsible input
% parameter sections:
%
% * *Link* - Contains link level parameters, such as frequency, bandwidth,
% required Eb/N0
% * *Transmitter* - Contains transmitter specific parameters
% * *Receiver* - Contains the receiver specific parameters
% * *Propagation* - Contains parameters to specify various atmospheric
% elements that are used to compute losses in the signal propagation path.

%% Results
% The *Results* tab contains *Uplink* and *Downlink* collapsible sections
% that provide the link budget results for uplink and downlink,
% respectively. The *Appendix* contains a list of functions used to compute
% the results.
%
% <<LinkBudgetAnalyzerResults.png>>
%
% * *Distance* and *Elevation* are computed from the *Latitude*,
% *Longitude* and *Altitude* input parameters for the transmitter and
% receiver.
% * *Tx Antenna gain* and *Rx Antenna gain* are functions of the
% corresponding *Antenna diameter*, *Antenna efficiency*, and *Frequency*
% input parameters.
% * *Tx EIRP* is a function of the *Amplifier power*, *Amplifier backoff
% loss*, *Feeder loss*, *Radome loss*, *Other losses*, and *Tx Antenna
% gain* input parameters. *Tx EIRP*, which represents transmitted
% equivalent isotropically radiated power (EIRP), is the amount of power
% that would have to be radiated by an isotropic antenna to produce the
% equivalent power density observed from the actual antenna in a specified
% direction. Typically, EIRP is quoted for antenna boresight, which is
% defined as the axis of maximum radiation.
% * The transmitted signal power is diminished by geometric spreading of
% the wavefront. This loss is represented by *Free space path loss* which
% is computed using the <docid:comm_ref#bsrduog fspl> function, *Distance*,
% and *Frequency*.
% * *Rain attenuation* is computed by the <docid:comm_ref#bu6e5ui rainpl>
% function using *Distance*, *Frequency*, *Rain rate*, *Elevation* and
% *Polarization tilt*. The <docid:comm_ref#bu6e5ui rainpl> function applies
% the International Telecommunication Union (ITU) rainfall attenuation
% model which applies only for frequencies at 1-1000 GHz [ <#5 1> ].
% * The <docid:comm_ref#bu6gf3c-1 fogpl> function computes *Fog/Cloud
% attenuation* using *Distance*, *Frequency*, *Fog/Cloud temperature* and
% *Fog/Cloud water density*. The <docid:comm_ref#bu6gf3c-1 fogpl> function
% applies the ITU cloud and fog attenuation model which is valid only for
% frequencies at 10-1000 GHz [ <#5 2> ].
% * *Atmospheric gas attenuation* is a function of *Distance*, *Frequency*,
% *Temperature*, *Atmospheric pressure* and *Water vapor density* and is
% calculated using the <docid:comm_ref#bu6ghsw-1 gaspl> function which applies
% ITU atmospheric gas attenuation model that is valid for frequencies at
% 1-1000 GHz [ <#5 3> ].
% * *Polarization loss* is derived from *Polarization mismatch* angle.
% * *Total propagation losses* consists of all the above-mentioned losses.
% 
% * *Tx EIRP* is diminished by *Total propagation losses* and receiver
% *Radome loss* to provide *Received isotropic power* at the receiver.
% * At the receiver, antenna amplifies the *Received isotropic power* by *Rx
% Antenna gain* while *Feeder loss* and *Other losses* degrade the signal.
% *Received signal power* shows the net result.
% * *Rx G/T* provides information on the performance of the receiver and is
% computed from *Rx Antenna gain* and *System temperature*. The receiver
% performance improves as G/T increases.
% * *C/N* represents SNR (Signal-to-Noise Ratio) and is a function of
% *Received signal power*, *System temperature*, *Bandwidth* and
% Boltzmann's constant.
% * *C/No* is computed from *C/N* and *Bandwidth*.
% * *Received Eb/No* indicates energy per bit and is a function of *C/No*
% and *Bit rate*.
% * *Margin* is computed from *Received Eb/No*, *Required Eb/No*, and
% *Implementation loss*. One goal when performing a link budget analysis is
% to have a satisfactory margin for the chosen data rate, bandwidth, EIRP
% and receiver figure of merit. Often some adjustment is needed to get the
% desired link margin.

%% Visualization
% For path loss and receiver performance plots, see the uplink and downlink
% FSPL and G/T tabs. Free space path loss constitutes the largest component
% of propagation losses. It is proportional to distance and frequency.
% Receiver figure of merit increases with antenna gain, which is
% proportional to antenna diameter. The specified *Frequency* and receiver
% *Antenna diameter* are shown by the red * marker in the plots.

%% Appendix
% Following functions are used to compute the various parameters and losses
% mentioned in this example:
%
% * <matlab:edit('comm.internal.linkBudgetApp.computeAntennaGain') comm.internal.linkBudgetApp.computeAntennaGain.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeAtmGasAtt') comm.internal.linkBudgetApp.computeAtmGasAtt.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeCbyN0') comm.internal.linkBudgetApp.computeCbyN0.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeCbyN') comm.internal.linkBudgetApp.computeCbyN.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeDistance') comm.internal.linkBudgetApp.computeDistance.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeEbN0') comm.internal.linkBudgetApp.computeEbN0.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeEIRP') comm.internal.linkBudgetApp.computeEIRP.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeFigureOfMerit') comm.internal.linkBudgetApp.computeFigureOfMerit.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeFogAtt') comm.internal.linkBudgetApp.computeFogAtt.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeFSPL') comm.internal.linkBudgetApp.computeFSPL.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeMargin') comm.internal.linkBudgetApp.computeMargin.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computePolarizationLoss') comm.internal.linkBudgetApp.computePolarizationLoss.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeRainAtt') comm.internal.linkBudgetApp.computeRainAtt.m>
% * <matlab:edit('comm.internal.linkBudgetApp.computeWavelength') comm.internal.linkBudgetApp.computeWavelength.m>


%% References
% # Radiocommunication Sector of International Telecommunication Union.
% Recommendation ITU-R P.838-3: Specific attenuation model for rain for use
% in prediction methods. 2005.
% # Radiocommunication Sector of International Telecommunication Union.
% Recommendation ITU-R P.840-6: Attenuation due to clouds and fog. 2013.
% # Radiocommunication Sector of International Telecommunication Union.
% Recommendation ITU-R P.676-10: Attenuation by atmospheric gases 2013.
