Package: comm
Adaptively adjust gain for constant signallevel output
The comm.AGC
System object™ creates an
automatic gain controller (AGC) that adaptively adjusts its gain to
achieve a constant signal level at the output.
To adaptively adjust gain for constant signallevel output:
Define and set up your automatic gain controller object. See Construction.
Call step
to adaptively adjust gain and achieve
a constant signal level at the output according to the properties
of comm.AGC
. The behavior of step
is
specific to each object in the toolbox.
Note:
Starting in R2016b, instead of using the 
H = comm.AGC
creates an AGC System object, H
,
that adaptively adjusts its gain to achieve a constant signal level
at the output.
H = comm.AGC(
creates
an AGC object, Name
,Value
)H
, with the specified property Name
set
to the specified Value
. You can specify additional
namevalue pair arguments in any order as (Name1
,Value1
,...,NameN
,ValueN
).

Step size for gain updates Specify the step size as a real positive scalar. The default
is  

Target output power level Specify the desired output power level as a real positive scalar.
The power is measured in Watts referenced to 1 ohm . The default is  

Length of the averaging window Specify the length of the averaging window in samples as a positive
integer scalar. The default is
 

Maximum power gain in decibels Specify the maximum gain of the AGC in decibels as a positive
scalar. The default is If the AGC input signal power is very small, the AGC gain will
be very large. This can cause problems when the input signal power
suddenly increases. Use 
clone  Create AGC object with same property
values 
isLocked  Locked status for input attributes and nontunable properties 
release  Allow property value and input characteristics changes 
reset  Reset internal states of automatic gain controller 
step  Apply adaptive gain to input signal 
For the logarithmic loop AGC, the output signal is the product of the input signal and the exponential of the loop gain. The error signal is the difference between the reference level and the product of the logarithm of the detector output and the exponential of the loop gain. After multiplying by the step size, the AGC passes the error signal to an integrator.
The logarithmic loop AGC provides good performance for a variety of signal types, including amplitude modulation. Unlike the previous AGC (R2015a and earlier), the detector is applied to the input signal, which results in faster convergence times and increased signal power variation at the detector input. The larger variation is not a problem for floating point systems. A block diagram of the algorithm is shown.
Mathematically, the algorithm is summarized as
$$\begin{array}{l}y(n)=x(n)\cdot \mathrm{exp}(g(n1))\\ z(n)=D(x(n))\cdot \mathrm{exp}(2g(n1))\\ e(n)=A\mathrm{ln}(z(n))\\ g(n)=g(n1)+K\cdot e(n),\end{array}$$
where
x represents the input signal.
y represents the output signal.
g represents the loop gain.
D(•) represents the detector function.
z represents the detector output.
A represents the reference value.
e represents the error signal.
K represents the step size.
The AGC uses a square law detector, in which the output of the detector, z, is given by
$$z(m)=\frac{1}{N}{\displaystyle {\sum}_{n=mN}^{(m+1)N1}{\lefty(n)\right}^{2}}\text{\hspace{0.17em}},$$
where N represents the update period.
Attack time — The duration it takes the AGC to respond to an increase in the input amplitude.
Decay time — The duration it takes the AGC to respond to a decrease in the input amplitude.
Gain pumping — The variation in the gain value during steadystate operation.
Increasing the step size decreases the attack time and decay times, but it also increases gain pumping.