Convert I/Q imbalance to compensator coefficient

Generate coefficients for the I/Q imbalance compensator System object™ using `iqimbal2coef`

. The compensator corrects for an I/Q imbalance using the generated coefficients.

Create a raised cosine transmit filter System object.

txRCosFilt = comm.RaisedCosineTransmitFilter;

Modulate and filter random 64-ary symbols.

M= 64; data = randi([0 M-1],100000,1); dataMod = qammod(data,M); txSig = txRCosFilt(dataMod);

Specify amplitude and phase imbalance.

ampImb = 2; % dB phImb = 15; % degrees

Apply the specified I/Q imbalance.

gainI = 10.^(0.5*ampImb/20); gainQ = 10.^(-0.5*ampImb/20); imbI = real(txSig)*gainI*exp(-0.5i*phImb*pi/180); imbQ = imag(txSig)*gainQ*exp(1i*(pi/2 + 0.5*phImb*pi/180)); rxSig = imbI + imbQ;

Normalize the power of the received signal.

rxSig = rxSig/std(rxSig);

Remove the I/Q imbalance by creating and applying a `comm.IQImbalanceCompensator`

object. Set the compensator such that the complex coefficients are made available as an output argument.

```
iqComp = comm.IQImbalanceCompensator('CoefficientOutputPort',true);
[compSig,coef] = iqComp(rxSig);
```

Compare the final compensator coefficient to the coefficient generated by the `iqimbal2coef`

function. Observe that there is good agreement.

idealcoef = iqimbal2coef(ampImb,phImb); [coef(end); idealcoef]

`ans = `*2×1 complex*
-0.1137 + 0.1296i
-0.1126 + 0.1334i

`A`

— Amplitude imbalancereal-valued scalar or vector

Amplitude imbalance in dB, specified as a real-valued row or column vector.

**Example: **`3`

**Example: **```
[0;
5]
```

**Data Types: **`single`

| `double`

`P`

— Phase imbalancereal-valued scalar or vector

Phase imbalance in degrees, specified as a real-valued row or column vector.

**Example: **`10`

**Example: **```
[15;
45]
```

**Data Types: **`single`

| `double`

The function `iqimbal2coef`

is
a supporting function for the `comm.IQImbalanceCompensator`

System object™.

Define **S** and **X** as
2-by-1 vectors representing the I and Q components of the ideal and
I/Q imbalanced signals, respectively.

$$X=K\cdot S$$

where **K** is a 2-by-2 matrix
whose values are determined by the amplitude imbalance, *A*,
and phase imbalance, *P*. *A* is
expressed in dB and * P* is expressed in degrees.

The imbalance can be expressed as:

$$\begin{array}{l}{I}_{gain}={10}^{0.5A/20}\\ {Q}_{gain}={10}^{-0.5A/20}\\ {\theta}_{i}=-\left(\frac{P}{2}\right)\left(\frac{\pi}{180}\right)\\ {\theta}_{q}=\frac{\pi}{2}+\left(\frac{P}{2}\right)\left(\frac{\pi}{180}\right)\end{array}$$

Then **K** has the form:

$$K=\left[\begin{array}{cc}{I}_{gain}\mathrm{cos}({\theta}_{i})& {Q}_{gain}\mathrm{cos}({\theta}_{q})\\ {I}_{gain}\mathrm{sin}({\theta}_{i})& {Q}_{gain}\mathrm{sin}({\theta}_{q})\end{array}\right]$$

The vector **Y** is defined as
the I/Q imbalance compensator output.

$$Y=R\cdot X$$

For the compensator to perfectly remove the I/Q imbalance, **R** must be the matrix inversion of **K**, namely:

$$R={K}^{-1}$$

Using complex notation, the vector **Y** can
be rewritten as:

$$\begin{array}{c}y={w}_{1}x+{w}_{2}\mathrm{conj}(x)\\ ={w}_{1}\left(x+\left(\raisebox{1ex}{${w}_{2}$}\!\left/ \!\raisebox{-1ex}{${w}_{1}$}\right.\right)\mathrm{conj}(x)\right)\end{array}$$

where,

$$\begin{array}{l}\mathrm{Re}\left\{{w}_{1}\right\}=({R}_{11}+{R}_{22})/2\\ \mathrm{Im}\left\{{w}_{1}\right\}=({R}_{21}-{R}_{12})/2\\ \mathrm{Re}\left\{{w}_{2}\right\}=({R}_{11}-{R}_{22})/2\\ \mathrm{Im}\left\{{w}_{2}\right\}=({R}_{21}+{R}_{12})/2\end{array}$$

The output of the function is *w _{2}*/

There are cases for which the output of `iqimbal2coef`

is unreliable.

If the phase imbalance is ±90°, the in-phase and quadrature components will become co-linear; consequently, the I/Q imbalance cannot be compensated.

If the amplitude imbalance is 0 dB and the phase imbalance is 180°,

*w*= 0 and_{1}*w*= 1i; therefore, the compensator takes the form of_{2}*y*= 1*i**conj(*x*).

Generate C and C++ code using MATLAB® Coder™.

A modified version of this example exists on your system. Do you want to open this version instead?

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web siteYou can also select a web site from the following list:

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

- América Latina (Español)
- Canada (English)
- United States (English)

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)