# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

Using Communications System Toolbox™ you can implement fading channels using objects or blocks. Rayleigh and Rician fading channels are useful models of real-world phenomena in wireless communications. These phenomena include multipath scattering effects, time dispersion, and Doppler shifts that arise from relative motion between the transmitter and receiver. This section gives a brief overview of fading channels and describes how to implement them using the toolbox.

The figure below depicts direct and major reflected paths between a stationary radio transmitter and a moving receiver. The shaded shapes represent reflectors such as buildings.

The major paths result in the arrival of delayed versions of the signal at the receiver. In addition, the radio signal undergoes scattering on a local scale for each major path. Such local scattering is typically characterized by a large number of reflections by objects near the mobile. These irresolvable components combine at the receiver and give rise to the phenomenon known as multipath fading. Due to this phenomenon, each major path behaves as a discrete fading path. Typically, the fading process is characterized by a Rayleigh distribution for a nonline-of-sight path and a Rician distribution for a line-of-sight path.

The relative motion between the transmitter and receiver causes Doppler shifts. Local scattering typically comes from many angles around the mobile. This scenario causes a range of Doppler shifts, known as the Doppler spectrum. The maximum Doppler shift corresponds to the local scattering components whose direction exactly opposes the mobile's trajectory.

The channel filter applies path gains to the signal in. The path gains are configured based upon settings chosen in the fading channel object or block.

These blocks and objects enable you to model SISO or MIMO fading channels.

#### Implement Fading Channel Using an Object

A baseband channel model for multipath propagation scenarios that you implement using objects includes:

• N discrete fading paths, each with its own delay and average power gain. A channel for which N = 1 is called a frequency-flat fading channel. A channel for which N > 1 is experienced as a frequency-selective fading channel by a signal of sufficiently wide bandwidth.

• A Rayleigh or Rician model for each path.

• Default channel path modeling using a Jakes Doppler spectrum, with a maximum Doppler shift that can be specified. Other types of Doppler spectra allowed (identical or different for all paths) include: flat, restricted Jakes, asymmetrical Jakes, Gaussian, bi-Gaussian, rounded, and bell.

If the maximum Doppler shift is set to 0 or omitted during the construction of a channel object, then the object models the channel as static. For this configuration the fading does not evolve with time and the Doppler spectrum specified has no effect on the fading process.

Some additional information about typical values for delays and gains is in Choosing Realistic Channel Property Values.

#### Implement Fading Channel Using a Block

The Channels block library includes MIMO and SISO fading blocks that can simulate real-world phenomena in mobile communications. These phenomena include multipath scattering effects, as well as Doppler shifts that arise from relative motion between the transmitter and receiver.

### Tip

To model a channel that involves both fading and additive white Gaussian noise, use a fading channel block connected in series with the AWGN Channel block, where the fading channel block comes first.

The MIMO Fading Channel and SISO Fading Channel blocks can be set to model Rayleigh or Rician fading distributions of the channel. Choose the fading distribution to use based on the type of signal path.

Direct line-of-sight path from transmitter to receiver `Rician`
One or more major reflected paths from transmitter to receiver `Rayleigh`

In the case of multiple major reflected paths, a single instance of a fading channel block configured for Rayleigh fading distribution can model all of them simultaneously.

Choosing appropriate block parameters for your situation is important. For more more information, see Choosing Realistic Channel Property Values, and the MIMO Fading Channel and SISO Fading Channel block reference pages.

You can view the characteristics of a fading channel using channel visualization tools. For more information, see Channel Visualization.

A communication system involving a fading channel usually requires component(s) that compensate for the fading response. Typical approaches to compensate for fading include:

• Differential modulation or a one-tap equalizer helps compensate for a frequency-flat fading channel. For information about implementing differential modulation, see the M-DPSK Modulator Baseband block reference page.

• An equalizer with multiple taps helps compensate for a frequency-selective fading channel. See Equalization for more information.

### Methodology for Simulating SISO Multipath Fading Channels

The Rayleigh and Rician multipath fading channel simulators in Communications System Toolbox™ use the band-limited discrete multipath channel model of section 9.1.3.5.2 in [1]. This implementation assumes that the delay power profile and the Doppler spectrum of the channel are separable [1]. The multipath fading channel is therefore modeled as a linear finite impulse-response (FIR) filter. Let $\left\{{s}_{i}\right\}$ denote the set of samples at the input to the channel. Then the samples $\left\{{y}_{i}\right\}$ at the output of the channel are related to $\left\{{s}_{i}\right\}$ through:

`${y}_{i}=\sum _{n=-{N}_{1}}^{{N}_{2}}{s}_{i-n}{g}_{n}$`

where $\left\{{g}_{n}\right\}$ is the set of tap weights given by:

In the equations above:

• ${T}_{s}$ is the input sample period to the channel.

• $\left\{{\tau }_{k}\right\}$, where $1\le k\le K$, is the set of path delays. K is the total number of paths in the multipath fading channel.

• $\left\{{a}_{k}\right\}$, where $1\le k\le K$, is the set of complex path gains of the multipath fading channel. These path gains are uncorrelated with each other.

• ${N}_{1}$ and ${N}_{2}$ are chosen so that $|{g}_{n}|$ is small when n is less than $-{N}_{1}$ or greater than ${N}_{2}$.

Two techniques, filtered Gaussian noise and sum-of-sinusoids, are used to generate the set of complex path gains, ${a}_{k}$.

Each path gain process ${a}_{k}$ is generated by the following steps:

Filtered Gaussian Noise Technique

1. A complex uncorrelated (white) Gaussian process with zero mean and unit variance is generated in discrete time.

2. The complex Gaussian process is filtered by a Doppler filter with frequency response $H\left(f\right)=\sqrt{S\left(f\right)}$, where $S\left(f\right)$ denotes the desired Doppler power spectrum.

3. The filtered complex Gaussian process is interpolated so that its sample period is consistent with that of the input signal. A combination of linear and polyphase interpolation is used.

Sum-of-sinusoids Technique

1. Mutually uncorrelated Rayleigh fading waveforms are generated using the method described in [2], where i = 1 corresponds to the in-phase component and i = 2 corresponds to the quadrature component.

`$\begin{array}{c}{z}_{k}\left(t\right)={\mu }_{k}^{\left(1\right)}\left(t\right)+j{\mu }_{k}^{\left(2\right)}\left(t\right),\text{ }k=1,2,\dots ,K\\ {\mu }_{k}^{\left(i\right)}\left(t\right)=\sqrt{\frac{2}{{N}_{k}}}\sum _{n=1}^{{N}_{k}}\mathrm{cos}\left(2\pi {f}_{k,n}^{\left(i\right)}t+{\theta }_{k,n}^{\left(i\right)}\right),\text{ }i=1,2\end{array}$`

Where

• Nk specifies the number of sinusoids used to model a single path.

• ${f}_{k,n}^{\left(i\right)}$ is the discrete Doppler frequency and is calculated for each sinusoid component within a single path.

• ${\theta }_{k,n}^{\left(i\right)}$ is the phase of the nth component of ${\mu }_{k}^{\left(i\right)}$ and is an i.i.d. random variable having a uniform distribution over the interval $\left(0,2\pi \right]$.

• t is the fading process time.

When modeling a Jakes Doppler spectrum, the discrete Doppler frequencies, ${f}_{k,n}^{\left(i\right)}$, with maximum shift fmax are given by

`$\begin{array}{c}{f}_{k,n}^{\left(i\right)}={f}_{\mathrm{max}}\mathrm{cos}\left({\alpha }_{k,n}^{\left(i\right)}\right)\\ ={f}_{\mathrm{max}}\mathrm{cos}\left[\frac{\pi }{2{N}_{k}}\left(n-\frac{1}{2}\right)+{\alpha }_{k,0}^{\left(i\right)}\right]\end{array}$`

where

`${\alpha }_{k,0}^{\left(i\right)}\triangleq {\left(-1\right)}^{i-1}\frac{\pi }{4{N}_{k}}\cdot \frac{k}{K+2},\text{ }i=1,\text{\hspace{0.17em}}2\text{\hspace{0.17em}}\text{\hspace{0.17em}}\text{and}\text{\hspace{0.17em}}\text{\hspace{0.17em}}k=1,2,\dots ,K$`
2. In order to advance the fading process in time, an initial time parameter, tinit, is introduced. The fading waveforms become

`${\mu }_{k}^{\left(i\right)}\left(t\right)=\sqrt{\frac{2}{{N}_{k}}}\sum _{n=1}^{{N}_{k}}\mathrm{cos}\left(2\pi {f}_{k,n}^{\left(i\right)}\left(t+{t}_{init}\right)+{\theta }_{k,n}^{\left(i\right)}\right),\text{ }i=1,2$`

When tinit = 0, the fading process starts at time zero. A positive value of tinit advances the fading process relative to time zero while maintaining its continuity.

3. Channel fading samples are generated using the GMEDS1 [2] algorithm.

Calculate Complex Coefficients

The complex process resulting from either technique, ${z}_{k}$, is scaled to obtain the correct average path gain. In the case of a Rayleigh channel, the fading process is obtained as:

`${a}_{k}=\sqrt{{\Omega }_{k}}{z}_{k}$`
where
`${\Omega }_{k}=E\left[{|{a}_{k}|}^{2}\right]$`
In the case of a Rician channel, the fading process is obtained as:
`${a}_{k}=\sqrt{{\Omega }_{k}}\left[\frac{{z}_{k}}{\sqrt{{K}_{r,k}+1}}+\sqrt{\frac{{K}_{r,k}}{{K}_{r,k}+1}}{e}^{j\left(2\pi {f}_{d,LOS,k}t+{\theta }_{LOS,k}\right)}\right]$`
where ${K}_{r,k}$ is the Rician K-factor of the k-th path, ${f}_{d,LOS,k}$ is the Doppler shift of the line-of-sight component of the k-th path (in Hz), and ${\theta }_{LOS,k}$ is the initial phase of the line-of-sight component of the k-th path (in rad).

At the input to the band-limited multipath channel model, the transmitted symbols must be oversampled by a factor at least equal to the bandwidth expansion factor introduced by pulse shaping. For example, if sinc pulse shaping is used, for which the bandwidth of the pulse-shaped signal is equal to the symbol rate, then the bandwidth expansion factor is 1, and at least one sample per symbol is required at the input to the channel. If a raised cosine (RC) filter with a factor in excess of 1 is used, for which the bandwidth of the pulse-shaped signal is equal to twice the symbol rate, then the bandwidth expansion factor is 2, and at least two samples per symbol are required at the input to the channel.

For additional information, see the article A Matlab-based Object-Oriented Approach to Multipath Fading Channel Simulation, located on MATLABCentral.

#### References

[1] Jeruchim, M. C., Balaban, P., and Shanmugan, K. S., Simulation of Communication Systems, Second Edition, New York, Kluwer Academic/Plenum, 2000.

[2] Pätzold, Matthias, Cheng-Xiang Wang, and Bjorn Olav Hogstand. “Two New Sum-of-Sinusoids-Based Methods for the Efficient Generation of Multiple Uncorrelated Rayleigh Fading Waveforms.” IEEE Transactions on Wireless Communications. Vol. 8, Number 6, 2009, pp. 3122–3131.

Communications System Toolbox models a fading channel as a linear FIR filter. Filtering a signal using a fading channel involves these steps:

1. Create a channel object that describes the channel that you want to use. A channel object is a type of MATLAB variable that contains information about the channel, such as the maximum Doppler shift.

2. Adjust properties of the channel object, if necessary, to tailor it to your needs. For example, you can change the path delays or average path gains.

3. Apply the channel object to your signal using calling the object.

This section describes how to define, inspect, and manipulate channel objects. The topics are:

#### Creating Channel Objects

Select one of these System objects to create a fading channel object suitable for you modeling situation.

FunctionObjectSituation Modeled

`comm.RayleighChannel`

Rayleigh fading channel objectOne or more major reflected paths

`comm.RicianChannel`

Rician fading channel objectOne direct line-of-sight path, possibly combined with one or more major reflected paths

For example, the command below creates a channel object representing a Rayleigh fading channel that acts on a signal sampled at 100,000 Hz. The maximum Doppler shift of the channel is 130 Hz.

```rayChan1 = comm.RayleighChannel('SampleRate',1e5,... 'MaximumDopplerShift',130); % Rayleigh fading channel object ```

To learn how to call the `rayChan1` fading channel object to filter the transmitted signal throught the channel, see Using Fading Channels.

#### Duplicate and Copy Objects

Another way to create an object is to duplicate an existing object and then adjust the properties of the new object, if necessary. If you do this, it is important to use a `copy` command such as

`rayChan2 = copy(rayChan1); % Copy rayChan1 to create an independent rayChan2.`

instead of `rayChan2 = rayChan1`. The `copy` command creates a copy of `rayChan1` that is independent of `rayChan1`. By contrast, the command ```rayChan2 = rayChan1``` creates `rayChan2` as merely a reference to `rayChan1`, so that `rayChan1` and `rayChan2` always have indistinguishable content.

#### Displaying and Changing Object Properties

A channel object has numerous properties that record information about the channel model, about the state of a channel that has already filtered a signal, and about the channel's operation on a future signal.

You can view the properties in these ways:

• To view all properties of a channel object, enter the object's name in the Command Window.

• To view a specific property of a channel object or to assign the property's value to a variable, enter the object's name followed by a dot (period), followed by the name of the property.

You can change the writable properties of a channel object in these ways:

• To change the default value of a channel object property, enter the desired value in the object creation syntax.

• To change the value of a writeable property of a channel object, issue an assignment statement that uses dot notation on the channel object. More specifically, dot notation means an expression that consists of the object's name, followed by a dot, followed by the name of the property.

Display Rayleigh Channel Object Properties

Create a Rayleigh channel object. Display the object to show the properties initialized by default and the ones specified when creating the object. Entering `rayChan` displays all properties of the channel object. Some of the properties values were assigned when the object was created, while other properties have default values. For more information about specific channel properties, see the reference page for the `comm.RayleighChannel` object.

```rayChan = comm.RayleighChannel('SampleRate',1e5,'MaximumDopplerShift',130); rayChan % View all the properties```
```rayChan = comm.RayleighChannel with properties: SampleRate: 100000 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 130 DopplerSpectrum: [1x1 struct] Show all properties ```
`g = rayChan.AveragePathGains % Retreive the AveragePathGains property of rayChan`
```g = 0 ```

A Rician fading channel object has an additional property that does not appear for a Rayleigh fading channel object, namely, a scalar `KFactor` property. For more information about Rician channel properties, see the reference page for the `comm.RicianChannel` object.

Change Rician Channel Object Properties

Create a Rician channel object. The default setting for the `Visualization` property is `'Off'`. Changing the default setting to `'Impulse response'` generates an impulse response plot of the output signal when the object is called.

```ricChan= comm.RicianChannel; % Create object ricChan.Visualization = 'Impulse response' % Enables the impulse response channel visualization```
```ricChan = comm.RicianChannel with properties: SampleRate: 1 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true KFactor: 3 DirectPathDopplerShift: 0 DirectPathInitialPhase: 0 MaximumDopplerShift: 1.0000e-03 DopplerSpectrum: [1x1 struct] Show all properties ```

The output displays a subset of all the properties of the channel object. Select `all properties` to see the complete set of properties for `ricChan`.

#### Relationships Among Channel Object Properties

Some properties of a channel object are related to each other such that when one property's value changes, another property's value must change in some corresponding way to keep the channel object consistent. For example, if you change the vector length of `PathDelays`, then the value of `AveragePathGains` must change so that its vector length equals that of the new value of `PathDelays`. This is because the length of each of the two vectors equals the number of discrete paths of the channel. For details about linked properties and an example, see the `comm.RayleighChannel` or `comm.RicianChannel`.

reference pages.

### Specify Doppler Spectrum of Fading Channel

The Doppler spectrum of a channel object is specified through its `DopplerSpectrum` property. The value of this property must be either:

• A Doppler object. In this case, the same Doppler spectrum applies to each path of the channel object.

• A cell array of Doppler objects of the same length as the `PathDelays` vector property. In this case, the Doppler spectrum of each path is given by the corresponding Doppler object in the vector.

• When the vector length of the PathDelays property is increased, the length of DopplerSpectrum is automatically increased to match the length of PathDelays, by appending Jakes Doppler objects.

• If the length of the PathDelays vector property is decreased, the length of DopplerSpectrum is automatically decreased to match the length of PathDelays, by removing the last Doppler object(s).

A Doppler object contains all the properties used to characterize the Doppler spectrum, with the exception of the maximum Doppler shift, which is a property of the channel object. This section describes how to create and manipulate Doppler objects, and how to assign them to the `DopplerSpectrum` property of channel objects.

#### Create a Doppler Object

To create Doppler objects, use the `doppler` function. The sole purpose of the `doppler` function is to create Doppler objects used to specify the value of the `DopplerSpectrum` property of channel objects.

If you assign a single Doppler spectrum structure to DopplerSpectrum, all paths have the same specified Doppler spectrum. If the FadingTechnique property is ```'Sum of sinusoids'```, DopplerSpectrum must be `doppler('Jakes')`; otherwise, select from the following:

• `doppler('Jakes')`

• `doppler('Flat')`

• `doppler('Rounded', ...)`

• `doppler('Bell', ...)`

• `doppler('Asymmetric Jakes', ...)`

• `doppler('Restricted Jakes', ...)`

• `doppler('Gaussian', ...)`

• `doppler('BiGaussian', ...)`

If you assign a row cell array of different Doppler spectrum structures (which can be chosen from any of those on the previous list) to DopplerSpectrum, each path has the Doppler spectrum specified by the corresponding structure in the cell array. In this case, the length of DopplerSpectrum must be equal to the length of `PathDelays`.

To generate C code, specify this property to a single Doppler spectrum structure.

For example, a Gaussian spectrum with a normalized (by the maximum Doppler shift of the channel) standard deviation of 0.1, can be created as:

`dopp1 = doppler('Gaussian',0.1);`

#### Duplicate Doppler Objects

As in the case of channel objects, Doppler objects can be duplicated using the `copy` function. The command:

`dopp2 = copy(dopp1);`

creates a Doppler object `dopp2` with the same properties as that of `dopp1`. `dopp1` and `dopp2` are then separate instances of a Doppler object, in that modifying either one will not affect the other. Using `dopp1 = dopp2` instead will cause both `dopp1` and `dopp2` to reference the same instance of a Doppler object, in that modifying either one will cause the same modification to the other.

#### View and Change Doppler Object Properties

The syntax for viewing and changing Doppler object properties is the same as for the case of channel objects (see Displaying and Changing Object Properties).

Create, change, and view a doppler object

A rounded Doppler object with default properties is created and displayed, and the third element of its `Polynomial` property is modified.

`doppRound = doppler('Rounded')`
```doppRound = struct with fields: SpectrumType: 'Rounded' Polynomial: [1 -1.7200 0.7850] ```

Adjust the third coefficient of the polynomial.

`doppRound.Polynomial(3) = 0.825`
```doppRound = struct with fields: SpectrumType: 'Rounded' Polynomial: [1 -1.7200 0.8250] ```

The property `SpectrumType`, which is common to all Doppler objects, is read-only. It is automatically specified at object construction, and cannot be modified. If you wish to use a different Doppler spectrum type, you need to create a new Doppler object of the desired type.

#### Use Doppler Objects Within Channel Objects

The `DopplerSpectrum` property of a channel object can be changed by assigning to it a Doppler object or a vector of Doppler objects.

#### Create Rayleigh Channel with Flat Doppler Spectrum

This example illustrates how to change the default Jakes Doppler spectrum of a constructed Rayleigh channel object to a flat Doppler spectrum:

Create a Rayleigh channel object

Set the sample rate to 9600 Hz and the maximum Doppler shfit to 100 Hz.

`rayChan = comm.RayleighChannel('SampleRate',9600, 'MaximumDopplerShift',100)`
```rayChan = comm.RayleighChannel with properties: SampleRate: 9600 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 100 DopplerSpectrum: [1x1 struct] Show all properties ```
`rayChan.DopplerSpectrum`
```ans = struct with fields: SpectrumType: 'Jakes' ```

Modify the Doppler spectrum

Create a flat doppler object and assign it in the `rayChan` object

`doppFlat = doppler('Flat')`
```doppFlat = struct with fields: SpectrumType: 'Flat' ```
`rayChan.DopplerSpectrum = doppFlat`
```rayChan = comm.RayleighChannel with properties: SampleRate: 9600 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 100 DopplerSpectrum: [1x1 struct] Show all properties ```
`rayChan.DopplerSpectrum`
```ans = struct with fields: SpectrumType: 'Flat' ```

#### Create Rician Channel with Gaussian Doppler Spectrum

This example shows how to change the default Jakes Doppler spectrum of a constructed Rician channel object to a Gaussian Doppler spectrum with normalized standard deviation of 0.3, and subsequently display the DopplerSpectrum property, and change the value of the normalized standard deviation to 1.1:

Create a Rician channel object

Set the sample rate to 9600 Hz, the maximum Doppler shfit to 100 Hz, and K factor to 2.

`ricChan = comm.RicianChannel('SampleRate',9600, 'MaximumDopplerShift',100, 'KFactor',2)`
```ricChan = comm.RicianChannel with properties: SampleRate: 9600 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true KFactor: 2 DirectPathDopplerShift: 0 DirectPathInitialPhase: 0 MaximumDopplerShift: 100 DopplerSpectrum: [1x1 struct] Show all properties ```
`ricChan.DopplerSpectrum`
```ans = struct with fields: SpectrumType: 'Jakes' ```

Modify the Doppler spectrum

Create a Gaussian doppler object with normalized standard deviation of 0.3 and assign it in the `ricChan` object.

`doppGaus = doppler('Gaussian',0.3)`
```doppGaus = struct with fields: SpectrumType: 'Gaussian' NormalizedStandardDeviation: 0.3000 ```
`ricChan.DopplerSpectrum = doppGaus`
```ricChan = comm.RicianChannel with properties: SampleRate: 9600 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true KFactor: 2 DirectPathDopplerShift: 0 DirectPathInitialPhase: 0 MaximumDopplerShift: 100 DopplerSpectrum: [1x1 struct] Show all properties ```
`ricChan.DopplerSpectrum`
```ans = struct with fields: SpectrumType: 'Gaussian' NormalizedStandardDeviation: 0.3000 ```
```ricChan.DopplerSpectrum.NormalizedStandardDeviation = 1.1; ricChan.DopplerSpectrum```
```ans = struct with fields: SpectrumType: 'Gaussian' NormalizedStandardDeviation: 1.1000 ```

#### Create Rayleigh Channel Using Independent Doppler Spectrum

This example illustrates how to change the default Jakes Doppler spectrum of a constructed three-path Rayleigh channel object to a cell array of different Doppler spectra, and then change the properties of the Doppler spectrum of the third path:

Create a Rayleigh channel object

Set the sample rate to 9600 Hz, the maximum Doppler shfit to 100 Hz, and specify path delays of `0`, `1e-4`, and `2.1e-4 seconds`.

`rayChan = comm.RayleighChannel('SampleRate',9600, 'MaximumDopplerShift',100, 'PathDelays',[0 1e-4 2.1e-4])`
```rayChan = comm.RayleighChannel with properties: SampleRate: 9600 PathDelays: [0 1.0000e-04 2.1000e-04] AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 100 DopplerSpectrum: [1x1 struct] Show all properties ```
`rayChan.DopplerSpectrum`
```ans = struct with fields: SpectrumType: 'Jakes' ```

Modify the Doppler spectrum

Specify the `DopplerSpectrum` property as a cell array with an independent Doppler spectrum for each path.

`rayChan.DopplerSpectrum = {doppler('Flat') doppler('Flat') doppler('Rounded')}`
```rayChan = comm.RayleighChannel with properties: SampleRate: 9600 PathDelays: [0 1.0000e-04 2.1000e-04] AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 100 DopplerSpectrum: {[1x1 struct] [1x1 struct] [1x1 struct]} Show all properties ```
`rayChan.DopplerSpectrum{:}`
```ans = struct with fields: SpectrumType: 'Flat' ```
```ans = struct with fields: SpectrumType: 'Flat' ```
```ans = struct with fields: SpectrumType: 'Rounded' Polynomial: [1 -1.7200 0.7850] ```

Change the `Polynomial` property for the third path.

`rayChan.DopplerSpectrum{3}.Polynomial = [1 -1.21 0.7]`
```rayChan = comm.RayleighChannel with properties: SampleRate: 9600 PathDelays: [0 1.0000e-04 2.1000e-04] AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 100 DopplerSpectrum: {[1x1 struct] [1x1 struct] [1x1 struct]} Show all properties ```
`rayChan.DopplerSpectrum{:}`
```ans = struct with fields: SpectrumType: 'Flat' ```
```ans = struct with fields: SpectrumType: 'Flat' ```
```ans = struct with fields: SpectrumType: 'Rounded' Polynomial: [1 -1.2100 0.7000] ```

### Configure Channel Objects

Before you filter a signal using a channel object, make sure that the properties of the channel have suitable values for the situation you want to model. This section offers some guidelines to help you choose realistic values that are appropriate for your modeling needs. The topics are

The syntaxes for viewing and changing values of properties of channel objects are described in Specifying a Fading Channel.

#### Choose Realistic Channel Property Values

Here are some tips for choosing property values that describe realistic channels:

Path Delays

• By convention, the first delay is typically set to zero. The first delay corresponds to the first arriving path.

• For indoor environments, path delays after the first are typically between 1 ns and 100 ns (that is, between 1e-9 s and 1e-7 s).

• For outdoor environments, path delays after the first are typically between 100 ns and 10 µs (that is, between 1e-7 s and 1e-5 s). Very large delays in this range might correspond, for example, to an area surrounded by mountains.

• The ability of a signal to resolve discrete paths is related to its bandwidth. If the difference between the largest and smallest path delays is less than about 1% of the symbol period, then the signal experiences the channel as if it had only one discrete path.

Average Path Gains

• The average path gains in the channel object indicate the average power gain of each fading path. In practice, an average path gain value is a large negative dB value. However, computer models typically use average path gains between -20 dB and 0 dB.

• The dB values in a vector of average path gains often decay roughly linearly as a function of delay, but the specific delay profile depends on the propagation environment.

• To ensure that the expected value of the path gains' total power is 1, you can normalize path gains via the channel object's `NormalizePathGains` property.

Maximum Doppler Shifts

• Some wireless applications, such as standard GSM (Global System for Mobile Communication) systems, prefer to specify Doppler shifts in terms of the speed of the mobile. If the mobile moves at speed v (m/s), then the maximum Doppler shift is calculated as follows, where f is the transmission carrier frequency in Hertz and c is the speed of light (3e8 m/s).

`${f}_{d}=\frac{vf}{c}$`
• Based on this formula in terms of the speed of the mobile, a signal from a moving car on a freeway might experience a maximum Doppler shift of about 80 Hz, while a signal from a moving pedestrian might experience a maximum Doppler shift of about 4 Hz. These figures assume a transmission carrier frequency of 900 MHz.

• A maximum Doppler shift of 0 corresponds to a static channel that comes from a Rayleigh or Rician distribution.

• The Rician K-factor specifies the ratio of specular-to-diffuse power for a direct line-of-sight path. The ratio is expressed linearly, not in dB.

• For Rician fading, the K-factor is typically between 1 and 10.

• A K-factor of 0 corresponds to Rayleigh fading.

Doppler Spectrum Parameters

• See the `doppler` reference page for the respective Doppler objects for descriptions of the parameters and their significance.

#### Configure Channel Objects Based on Simulation Needs

Tips for configuring a channel object to customize the filtering process:

• If your data is partitioned into a series of vectors (that you process within a loop, for example), you can call the channel object multiple times (in each iteration within a loop). The channel's state information is updated and saved after each invocation. The channel output is irrelevant to how the data is partitioned (vector length).

• If want the channel output to be repeatable, choose the seed option for the `RandomStream` property of the channel object. To repeat the output, call the `reset` object function to reset both the internal filters and the internal random number generator.

• If you want to model discontinuously transmitted data, set the `FadingTechnique` property to `'Sum of sinusoids'` and the `InitialTimeSource` property to ```'Input port'``` for the channel object. When calling the object, specify the start time of each data vector/frame to be processed by the channel via an input.

• If you want to normalize the fading process so that the expected value of the path gains' total power is 1 (the channel does not contribute additional power gain or loss), set the `NormalizePathGains` property of the channel object to `true`.

#### Store Channel State History

By default, the `PathGains` property of a channel object stores the current complex path gain vector.

Setting the `StoreHistory` property of a channel to true makes it store the last N path gain vectors, where N is the length of the vector processed through the channel. The following code illustrates this property

```rayChan = comm.RayleighChannel('SampleRate',100000,'MaximumDopplerShift',130); % Rayleigh channel tx = randi([0 1],10,1); % Random bit stream hmod = comm.DBPSKModulator; % Create DBPSK Modulator dpskSig = step(hmod,tx); % Process data by calling the step method rayChan.StoreHistory = true; % Allow states to be stored y = filter(h, dpskSig); % Run signal through channel h.PathGains % Display the stored path gains data ```

This example generates an output similar to the following:

``` -0.7601 - 1.1853i -0.7540 - 1.1822i -0.7480 - 1.1791i -0.7419 - 1.1759i -0.7358 - 1.1728i -0.7298 - 1.1696i -0.7237 - 1.1665i -0.7177 - 1.1634i -0.7115 - 1.1599i -0.7053 - 1.1565i```
```ans = 0.0788 - 0.5305i```

The last element is the current path gain of the channel.

Setting `StoreHistory` to true significantly slows down the execution speed of the channel's filter function.

After you have created a channel object as described in Specifying a Fading Channel, you can call the object to pass a signal through the channel. Provide the signal as an input argument to the channel object. At the end of the filtering operation, the channel object retains its state so that you can find out the final path gains or the total number of samples that the channel has processed by calling the info object function with the object as the input argument.

For an example that illustrates the basic syntax and state retention, see Power of a Faded Signal.

To visualize the chararteristics of the channel use set `Visualization` property to `'Impulse response'`, `'Frequency response'`, or `'Doppler spectrum'`. For more information, see Channel Visualization.

#### Visualize Three-Path Rayleigh Channel

This examples shows you how to visualize impulse response of a channel.

Create a channel object

While creating the channel object, use name-value pairs to set the `Visualization` property

to `'Impulse response'`.

```rayChan = comm.RayleighChannel('SampleRate',100000,'MaximumDopplerShift',130,... 'PathDelays',[0 1.5e-5 3.2e-5],'AveragePathGains',[0, -3, -3],... 'Visualization','Impulse response');```

Generate a bit stream and create a modulator object. Modulate the bit stream and pass the

modulated DBPSK signal through the channel by calling the channel object.

```tx = randi([0 1],500,1); dbspkMod = comm.DBPSKModulator; dpskSig = dbspkMod(tx); y = rayChan(dpskSig);```

The impulse response is plotted when the object is called.

This example plots the power of a faded signal versus sample number. It illustrates the syntax of creating and calling a `comm.RayleighChannel` fading channel object and the state retention of the channel object.

```rayChan = comm.RayleighChannel('SampleRate',10000,'MaximumDopplerShift',100); sig = j*ones(2000,1); % Signal out = rayChan(sig); % Pass signal through channel. rayChan % Display all properties of the channel object.```
```rayChan = comm.RayleighChannel with properties: SampleRate: 10000 PathDelays: 0 AveragePathGains: 0 NormalizePathGains: true MaximumDopplerShift: 100 DopplerSpectrum: [1x1 struct] Show all properties ```
```% Plot power of faded signal, versus sample number. plot(20*log10(abs(out)))```

#### DBPSK Empirical Versus Theoretical Performance in Fading Conditions

This example creates a frequency-flat Rayleigh fading channel object and calls it to process a DBPSK signal consisting of a single vector. Bit error rate is computed for different values of the signal-to-noise ratio. The fading channel filter is applied before before AWGN. This is the recommended sequence to use when you combine fading with AWGN.

Create Rayleigh fading channel, modulator, and demodulator objects

`chan = comm.RayleighChannel('SampleRate',1e4,'MaximumDopplerShift',100);`

Create DBPSK modulator and demodulator objects with the modulation order set to `2`. Generate DBPSK modulated data and pass it through the channel.

```M = 2; % DBPSK modulation order tx = randi([0 M-1],50000,1); % Generate a random bit stream mod = comm.DBPSKModulator; demod = comm.DBPSKDemodulator; dpskSig = mod(tx); fadedSig = chan(dpskSig); % Apply the channel effects```

Create an AWGN Channel object and ErrorRate calculator System object.

```awgnChan = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)'); errorCalc = comm.ErrorRate;```

Compute error rate for different values of SNR.

```SNR = 0:2:20; % Range of SNR values, in dB. numSNR = length(SNR); berVec = zeros(3, numSNR); % Preallocate a vector for BER results for n = 1:numSNR awgnChan.SNR = SNR(n); rxSig = awgnChan(fadedSig); % Add Gaussian noise rx = demod(rxSig); % Demodulate reset(errorCalc) berVec(:,n) = errorCalc(tx,rx); % Compute error rate. end BER = berVec(1,:);```

Compute theoretical performance results, for comparison.

`BERtheory = berfading(SNR,'dpsk',M,1);`

Plot BER results.

```semilogy(SNR,BERtheory,'b-',SNR,BER,'r*'); legend('Theoretical BER','Empirical BER'); xlabel('SNR (dB)'); ylabel('BER'); title('Binary DPSK over Rayleigh Fading Channel');```

#### Work with Channel Filter Delays

The value of a channel object's ChannelFilterDelay property is the number of samples by which the output of the channel lags the input. If you compare the input and output data sets directly, you must take the delay into account by using appropriate truncating or padding operations.

The example illustrates a way to account for the delay before computing a bit error rate.

Create DBPSK modulator and demodulator objects with the modulation order set to `2`. Generate DBPSK modulated data and pass it through the channel.

```bitRate = 50000; M = 2; % DQPSK modulation order mod = comm.DBPSKModulator; demod = comm.DBPSKDemodulator; ```

```rayChan = comm.RayleighChannel('SampleRate',bitRate,'MaximumDopplerShift',4,... 'PathDelays',[0 0.5/bitRate],'AveragePathGains',[0 -10]); chInfo = info(rayChan); delay = chInfo.ChannelFilterDelay;```

Generate random bit stream data. Modulate the data, pass it through the fading channel, and demodulate it.

```tx = randi([0 M-1],50000,1); dpskSig = mod(tx); fadedSig = rayChan(dpskSig); rx = demod(fadedSig); ```

Compute bit error rate, taking delay into account.

```errorCalc = comm.ErrorRate('ReceiveDelay', delay); berVec = step(errorCalc,tx,rx); ber = berVec(1)```
```ber = 0.0152 ```
`num = berVec(2)`
```num = 760 ```

#### Channel Filtering Using a For Loop

This example filters input dat through a Rayliegh fading channel within a `for` loop. It uses the small data sets from successive iterations to create an animated effect. The Rayleigh fading channel has two discrete major paths. For information on indicates how to filter data through a channel multiple times while maintaining continuity from one invocation to the next, see Configure Channel Objects Based on Simulation Needs.

Set up parameters. Specify a bit rate of `50e3` Hz, and a loop iteration count of `125`. Create a QPSK modulator and Rayleigh fading channel objects.

```bitRate = 50000; % Data rate is 50 kb/s numTrials = 125; % Number of iterations of loop M = 4; % QPSK modulation order qpskMod = comm.QPSKModulator; rayChan = comm.RayleighChannel('SampleRate',bitRate,'MaximumDopplerShift',4,'PathDelays',[0 2e-5],'AveragePathGains',[0 -9]); ```

Initialize a scatter plot.

```scatterPlot = comm.ConstellationDiagram; ```

Apply channel in a loop, maintaining continuity. Plot only the current data in each iteration.

```for n = 1:numTrials tx = randi([0 M-1],500,1); % Generate random bit stream pskSig = qpskMod(tx); % PSK modulate signal fadedSig = rayChan(pskSig); % Apply channel effects % Plot the new data from this iteration. update(scatterPlot,fadedSig); end```