The function `iqcoef2imbal`

is
a supporting function for the `comm.IQImbalanceCompensator`

System object™.

Given a scaling and rotation factor, *G*, compensator
coefficient, *C*, and received signal, *x*,
the compensated signal, *y*, has the form

In matrix form, this can be rewritten as

where **X** is a 2-by-1 vector
representing the imbalanced signal [*X*_{I}, *X*_{Q}]
and **Y** is a 2-by-1 vector representing
the compensator output [*Y*_{I}, *Y*_{Q}].

The matrix **R** is expressed as

For the compensator to perfectly remove the I/Q imbalance, **R** = **K**^{-1} because $$X=K\text{\hspace{0.17em}}S$$, where **K** is a 2-by-2 matrix whose values are determined
by the amplitude and phase imbalance and **S** is
the ideal signal. Define a matrix **M** with
the form

Both **M** and **M**^{-1} can
be thought of as scaling and rotation matrices that correspond to
the factor *G*. Because **K** = **R**^{-1}, the product **M**^{-1} **R** **K** **M** is the identity matrix, where **M**^{-1} **R** represents the compensator output and **K** **M** represents
the I/Q imbalance. The coefficient *α* is chosen
such that

where *L* is a constant. From this form, we
can obtain *I*_{gain}, *Q*_{gain}, *θ*_{I},
and *θ*_{Q}. For a given
phase imbalance, *Φ*_{Imb},
the in-phase and quadrature angles can be expressed as

Hence, cos(*θ*_{Q})
= sin(*θ*_{I}) and sin(*θ*_{Q})
= cos(*θ*_{I}) so
that

The I/Q imbalance can be expressed as

Therefore,

The equation can be written as a quadratic equation to solve
for the variable *α*, that is *D*_{1}α^{2} + *D*_{2}α + *D*_{3} =
0, where

When |*C*| ≤ 1,
the quadratic equation has the following solution:

Otherwise, when |*C*| >
1, the solution has the following form:

Finally, the amplitude imbalance, *A*_{Imb},
and the phase imbalance, *Φ*_{Imb},
are obtained.

**Note**

If *C* is real and |*C*| ≤ 1, the phase imbalance is 0 and the amplitude
imbalance is 20log_{10}((1–*C*)/(1+*C*))

If *C* is real and |*C*| > 1, the phase imbalance is 180° and the
amplitude imbalance is 20log_{10}((*C*+1)/(*C*−1)).

If *C* is imaginary, *A*_{Imb} =
0.