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.
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, and rounded.
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 (i.e., 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 Choose Realistic Channel Property Values
The Channels block library includes Rayleigh and Rician 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.
Note 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 table below indicates the situations in which each fading channel block is appropriate.
|Signal Path||Channel Block|
|Direct line-of-sight path from transmitter to receiver||Multipath Rician Fading Channel|
|One or more major reflected paths from transmitter to receiver||Multipath Rayleigh Fading Channel|
In the case of multiple major reflected paths, a single instance of the Multipath Rayleigh Fading Channel block can model all of them simultaneously. The number of paths that the block uses is the length of either the Delay vector or the Gain vector parameter, whichever length is larger. (If both of these parameters are vectors, they must have the same length; if exactly one of these parameters is a scalar, the block expands it into a vector whose size matches that of the other vector parameter.)
Choosing appropriate block parameters for your situation is important. For more details about the parameters of fading channel blocks, see
The Choose Realistic Channel Property Values section under "Configuring Channel Objects" in the Communications System Toolbox documentation
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. See the M-DPSK Modulator Baseband block Help page or the example in Compare Empirical Results to Theoretical Results for information about implementing differential modulation.
An equalizer with multiple taps helps compensate for a frequency-selective fading channel. See Equalization for more information.
with Adaptive Equalization example illustrates why
compensating for a fading channel is necessary.
You can plot a fading channel's characteristics using channel visualization tools.
For communication systems that you implement using objects, see Channel Visualization.
For communication systems that you implement using blocks, there are two ways to visualize fading channel response. One way is to double-click the block during a simulation. The second way is to select Open channel visualization at start of simulation in the block dialog box.
The Rayleigh and Rician multipath fading channel simulators in Communications System Toolbox use the band-limited discrete multipath channel model of section 188.8.131.52.2 in . This implementation assumes that the delay power profile and the Doppler spectrum of the channel are separable . The multipath fading channel is therefore modeled as a linear finite impulse-response (FIR) filter. Let denote the set of samples at the input to the channel. Then the samples at the output of the channel are related to through:
where is the set of tap weights given by:
In the equations above:
is the input sample period to the channel.
, where , is the set of path delays. K is the total number of paths in the multipath fading channel.
, where , is the set of complex path gains of the multipath fading channel. These path gains are uncorrelated with each other.
and are chosen so that is small when n is less than or greater than .
Two techniques, filtered Gaussian noise and sum-of-sinusoids, are used to generate the set of complex path gains, .
Each path gain process is generated by the following steps:
Filtered Gaussian Noise Technique
A complex uncorrelated (white) Gaussian process with zero mean and unit variance is generated in discrete time.
The complex Gaussian process is filtered by a Doppler filter with frequency response , where denotes the desired Doppler power spectrum.
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.
Mutually uncorrelated Rayleigh fading waveforms are generated using the method described in , where i = 1 corresponds to the in-phase component and i = 2 corresponds to the quadrature component.
Nk specifies the number of sinusoids used to model a single path.
is the discrete Doppler frequency and is calculated for each sinusoid component within a single path.
is the phase of the nth component of and is an i.i.d. random variable having a uniform distribution over the interval .
t is the fading process time.
The discrete Doppler frequencies, , with maximum shift fmax are given by
In order to advance the fading process in time, an initial time parameter, tinit, is introduced. The fading waveforms become
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.
Channel fading samples are generated using the GMEDS1  algorithm.
Calculate Complex Coefficients
The complex process resulting from either technique, , is scaled to obtain the correct average path gain. In the case of a Rayleigh channel, the fading process is obtained as:
In the case of a Rician channel, the fading process is obtained as:
where is the Rician K-factor of the k-th path, is the Doppler shift of the line-of-sight component of the k-th path (in Hz), and 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 MATLAB®Central.
 Jeruchim, M. C., Balaban, P., and Shanmugan, K. S., Simulation of Communication Systems, Second Edition, New York, Kluwer Academic/Plenum, 2000.
 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:
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.
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.
Note: Setting the maximum path delay greater than 100 samples may generate an ‘Out of memory' error.
Apply the channel object to your signal using the
This section describes how to define, inspect, and manipulate channel objects. The topics are:
|Rayleigh fading channel object||One or more major reflected paths|
|Rician fading channel object||One 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.
c1 = rayleighchan(1/100000,130); % Rayleigh fading channel object
c1 is a valid input argument for
filter function. To learn how to use the
to filter a signal using a channel object, see Use 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
c2 = copy(c1); % Copy c1 to create an independent c2.
c2 = c1. The
creates a copy of
c1 that is independent of
By contrast, the command
c2 = c1 creates
merely a reference to
c1, so that
have indistinguishable content.
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.
In the example below, entering
c1 causes MATLAB to
display all properties of the channel object
Some of the properties have values from the
c1, while other properties have default
c1 = rayleighchan(1/100000,130); % Create object. c1 % View all properties of c1. g = c1.PathGains % Retrieve the PathGains property of c1.
The output is
c1 = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0000e-005 DopplerSpectrum: [1x1 doppler.jakes] MaxDopplerShift: 130 PathDelays: 0 AvgPathGaindB: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: -0.0428 + 0.4732i ChannelFilterDelay: 0 ResetBeforeFiltering: 1 NumSamplesProcessed: 0 g = -0.0428 + 0.4732i
A Rician fading channel object has an additional property that
does not appear above, namely, a scalar
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.
The example below illustrates how to change the
indicating you do not want to reset the channel before each filtering
c1 = rayleighchan(1/100000,130) % Create object. c1.ResetBeforeFiltering = 0 % Do not reset before filtering.
The output below displays all the properties of the channel
object before and after the change in the value of the
In the second listing of properties, the
has the value
c1 = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0000e-005 DopplerSpectrum: [1x1 doppler.jakes] MaxDopplerShift: 130 PathDelays: 0 AvgPathGaindB: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: 0.5781 + 0.9020i ChannelFilterDelay: 0 ResetBeforeFiltering: 1 NumSamplesProcessed: 0 c1 = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0000e-005 DopplerSpectrum: [1x1 doppler.jakes] MaxDopplerShift: 130 PathDelays: 0 AvgPathGaindB: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: 0.5781 + 0.9020i ChannelFilterDelay: 0 ResetBeforeFiltering: 0 NumSamplesProcessed: 0
Some properties of a channel object are read-only. For example,
you cannot assign a new value to the
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
then the value of
AvgPathGaindB must change so
that its vector length equals that of the new value of
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 reference page for
The Doppler spectrum of a channel object is specified through
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 vector of Doppler objects of the same length as
PathDelays vector property. In this case, the
Doppler spectrum of each path is given by the corresponding Doppler
object in the vector.
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
The sole purpose of Doppler objects is to specify the value
DopplerSpectrum property of channel objects.
Doppler objects can be created using one of seven functions:
doppler.rounded. For a description
of each of these functions and the underlying theory, refer to their
corresponding reference pages.
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:
d = doppler.gaussian(0.1);
As in the case of channel objects, Doppler objects can be duplicated
copy function. The command:
d2 = copy(d1);
creates a Doppler object
d2 with the same
properties as that of
then separate instances of a Doppler object, in that modifying either
one will not affect the other. Using
d1 = d2 instead
will cause both
reference the same instance of a Doppler object, in that modifying
either one will cause the same modification to the other.
The syntax for viewing and changing Doppler object properties
is the same as for the case of channel objects (see Display Object Properties and Change Object Properties). The
disp can be used with Doppler objects
to display their properties.
In the following example, a rounded Doppler object with default
properties is created and displayed, and the third element of its
dr = doppler.rounded dr = SpectrumType: 'Rounded' CoeffRounded: [1 -1.7200 0.7850] dr.CoeffRounded(3) = 0.8250 dr = SpectrumType: 'Rounded' CoeffRounded: [1 -1.7200 0.8250]
Note that the property
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.
DopplerSpectrum property of a channel
object can be changed by assigning to it a Doppler object or a vector
of Doppler objects. The following example illustrates how to change
the default Jakes Doppler spectrum of a constructed Rayleigh channel
object to a flat Doppler spectrum:
>> h = rayleighchan(1/9600, 100) h = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0417e-004 DopplerSpectrum: [1x1 doppler.jakes] MaxDopplerShift: 100 PathDelays: 0 AvgPathGaindB: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: -0.4007 - 0.2748i ChannelFilterDelay: 0 ResetBeforeFiltering: 1 NumSamplesProcessed: 0 >> dop_flat = doppler.flat dop_flat = SpectrumType: 'Flat' >> h.DopplerSpectrum = dop_flat h = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0417e-004 DopplerSpectrum: [1x1 doppler.flat] MaxDopplerShift: 100 PathDelays: 0 AvgPathGaindB: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: -0.4121 - 0.2536i ChannelFilterDelay: 0 ResetBeforeFiltering: 1 NumSamplesProcessed: 0
The following 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
DopplerSpectrum property, and change
the value of the normalized standard deviation to 1.1:
>> h = ricianchan(1/9600, 100, 2); >> h.DopplerSpectrum = doppler.gaussian(0.3) h = ChannelType: 'Rician' InputSamplePeriod: 1.0417e-004 DopplerSpectrum: [1x1 doppler.gaussian] MaxDopplerShift: 100 PathDelays: 0 AvgPathGaindB: 0 KFactor: 2 DirectPathDopplerShift: 0 DirectPathInitPhase: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: 0.8073 - 0.0769i ChannelFilterDelay: 0 ResetBeforeFiltering: 1 NumSamplesProcessed: 0 >> h.DopplerSpectrum ans = SpectrumType: 'Gaussian' SigmaGaussian: 0.3000 >> h.DopplerSpectrum.SigmaGaussian = 1.1;
The following example illustrates how to change the default Jakes Doppler spectrum of a constructed three-path Rayleigh channel object to a vector of different Doppler spectra, and then change the properties of the Doppler spectrum of the third path:
>> h = rayleighchan(1/9600, 100, [0 1e-4 2.1e-4]); >> h.DopplerSpectrum = [doppler.flat doppler.flat doppler.rounded] h = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0417e-004 DopplerSpectrum: [3x1 doppler.baseclass] MaxDopplerShift: 100 PathDelays: [0 1.0000e-004 2.1000e-004] AvgPathGaindB: [0 0 0] NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: [0.4233 - 0.1113i -0.0785 + 0.1667i -0.2064 + 0.3531i] ChannelFilterDelay: 3 ResetBeforeFiltering: 1 NumSamplesProcessed: 0 >> h.DopplerSpectrum(3).CoeffRounded = [1 -1.21 0.7];
DopplerSpectrum property of a channel
object is a vector:
If the length of the
property is increased, the length of
automatically increased to match the length of
by appending Jakes Doppler objects.
If the length of the
property is decreased, the length of
automatically decreased to match the length of
by removing the last Doppler object(s).
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 Specify Fading Channels.
Here are some tips for choosing property values that describe realistic channels:
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.
Note: Setting the maximum path delay greater than 100 samples may generate an ‘Out of memory' error.
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
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).
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.
K-Factor for Rician Fading Channels
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 reference pages for the respective Doppler objects for descriptions of the parameters and their significance.
Here are some 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 invoke the
multiple times while automatically saving the channel's state information
for use in a subsequent invocation. The state information is visible
to you in the channel object's
but also involves properties that are internal rather than visible.
To maintain continuity from one invocation to the next, you
must set the
If you set the
of the channel object to
0 and want the randomness
to be repeatable, use the
reset function before
filtering any signals to reset both the channel and the state of the
internal random number generator.
If you want to reset the channel before a filtering
operation so that it does not use any previously stored state information,
either use the
reset function or set the
of the channel object to
1. The former method resets
the channel object once, while the latter method causes the
to reset the channel object each time you invoke it.
If you want to normalize the fading process so that
the expected value of the path gains' total power is 1, set the
of the channel object to
After you have created a channel object as described in Specify Fading Channels, you
can use the
filter function to pass a signal
through the channel. The arguments to
the channel object and the signal. 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 since it was created or reset. If you configured the channel
to avoid resetting its state before each new filtering operation (
then the retention of state information is important for maintaining
continuity between successive filtering operations.
For an example that illustrates the basic syntax and state retention, see Power of a Faded Signal.
If you want to use the channel visualization tool to plot the
characteristics of a channel object, you need to set the
of the channel object to
1 so that it is populated
with plot information. See Channel Visualization for details.
The following examples use fading channels:
The code below plots a faded signal's power (versus sample number).
The code also illustrates the syntax of the
and the state retention of the channel object. Notice from the output
NumSamplesProcessed equals the number of elements
sig, the signal.
c = rayleighchan(1/10000,100); sig = 1i*ones(2000,1); % Generate signal y = filter(c,sig); % Pass signal through channel c % Display all properties of the channel % Plot power of faded signal, versus sample number. plot(20*log10(abs(y)))
The output and the plot follow.
c = ChannelType: 'Rayleigh' InputSamplePeriod: 1.0000e-004 DopplerSpectrum: [1x1 doppler.jakes] MaxDopplerShift: 100 PathDelays: 0 AvgPathGaindB: 0 NormalizePathGains: 1 StoreHistory: 0 StorePathGains: 0 PathGains: -0.8062 + 0.2648i ChannelFilterDelay: 0 ResetBeforeFiltering: 1 NumSamplesProcessed: 2000
The code below creates a frequency-flat Rayleigh fading channel
object and uses it to process a DBPSK signal consisting of a single
vector. The example continues by computing the bit error rate of the
system for different values of the signal-to-noise ratio. Notice that
the example uses
this is the recommended sequence to use when you combine fading with
% Create Rayleigh fading channel object. chan = rayleighchan(1/10000,100); % Generate data and apply fading channel. M = 2; % DBPSK modulation order hMod = comm.DBPSKModulator; % Create a DPSK modulator hDemod = comm.DBPSKDemodulator; % Create a DPSK demodulator tx = randi([0 M-1],50000,1); % Generate a random bit stream dpskSig = step(hMod, tx); % DPSK modulate the signal fadedSig = filter(chan,dpskSig); % Apply the channel effects % 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); % Create an AWGNChannel and ErrorRate calculator System object hChan = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)'); hErrorCalc = comm.ErrorRate; for n = 1:numSNR hChan.SNR = SNR(n); rxSig = step(hChan,fadedSig); % Add Gaussian noise rx = step(hDemod, rxSig); % Demodulate reset(hErrorCalc) % Compute error rate. berVec(:,n) = step(hErrorCalc,tx,rx); 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');
With the parameters in the preceding code, the fading is slow enough to be considered the same across two consecutive samples.
The resulting plot shows that the simulation results are close
to the theoretical results computed by
The value of a channel object's
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
The example illustrates one way to account for the delay before computing a bit error rate.
M = 2; % DQPSK modulation order bitRate = 50000; hMod = comm.DBPSKModulator; % Create a DPSK modulator hDemod = comm.DBPSKDemodulator; % Create a DPSK demodulator % Create Rayleigh fading channel object. ch = rayleighchan(1/bitRate,4,[0 0.5/bitRate],[0 -10]); delay = ch.ChannelFilterDelay; tx = randi([0 M-1],50000,1); % Generate random bit stream dpskSig = step(hMod,tx); % DPSK modulate signal fadedSig = filter(ch,dpskSig); % Apply channel effects rx = step(hDemod,fadedSig); % Demodulate signal % Compute bit error rate, taking delay into account. hErrorCalc = comm.ErrorRate('ReceiveDelay', delay); berVec = step(hErrorCalc,tx,rx); ber = berVec(1) num = berVec(2)
The output below shows that the error rate is small. If the example had not compensated for the channel delay, the error rate would have been close to 1/2.
num = 845 ber = 0.0170
The section Configure Channel Objects Based on Simulation Needs indicates
how to invoke the
filter function multiple times
while maintaining continuity from one invocation to the next. The
example below invokes
filter within a loop and
uses the small data sets from successive iterations to create an animated
effect. The particular channel in this example is a Rayleigh fading
channel with two discrete major paths.
% Set up parameters. M = 4; % QPSK modulation order hMod = comm.QPSKModulator; bitRate = 50000; % Data rate is 50 kb/s numTrials = 125; % Number of iterations of loop % Create Rayleigh fading channel object. ch = rayleighchan(1/bitRate,4,[0 2e-5],[0 -9]); % Indicate that FILTER should not reset the channel % in each iteration below. ch.ResetBeforeFiltering = 0; % Initialize scatter plot. hConst = 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 = step(hMod,tx); % PSK modulate signal fadedSig = filter(ch, pskSig); % Apply channel effects % Plot the new data from this iteration. step(hConst,fadedSig); end
The scatter plot changes with each iteration of the loop, and the exact content varies because the fading process involves random numbers.
By default, the
PathGains property of a
channel object stores the current complex path gain vector.
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
h = rayleighchan(1/100000, 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 h.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.
StoreHistory to true significantly
slows down the execution speed of the channel's filter function.
Communications System Toolbox software provides a plotting function that helps you visualize the characteristics of a fading channel using a GUI. See Fading Channels for a description of fading channels and objects.
To open the channel visualization tool, type
the command line, where
h is a channel object that
contains plot information. To populate a channel object with plot
information, run a signal through it after setting its
StoreHistory property to
For example, the following code opens the channel visualization tool showing a three-path Rayleigh channel through which a random signal is passed:
% Three-Path Rayleigh channel h = rayleighchan(1/100000, 130, [0 1.5e-5 3.2e-5], [0, -3, -3]); tx = randi([0 1],500,1); % Random bit stream hmod = comm.DBPSKModulator; % Create DBPSKModulator dpskSig = step(hmod,tx); % DPSK signal h.StoreHistory = true; % Allow states to be stored y = filter(h, dpskSig); % Run signal through channel plot(h); % Call Channel Visualization Tool
See Examples of Using the Channel Visualization Tool for the basic usage cases of the channel visualization tool.
This tool can also be accessed from Communications System Toolbox software.
Parts of the GUI. The Visualization pull-down menu allows you to choose the visualization method.
The Frame count counter shows the index of the current frame. It shows the number of frames processed by the filter method since the channel object was constructed or reset. A frame is a vector of M elements, interpreted to be M successive samples that are uniformly spaced in time, with a sample period equal to that specified for the channel.
The Sample index slider control indicates
which channel snapshot is currently being displayed, while the Pause button
pauses a running animation until you click it again. The slider control
and Pause button apply to all visualizations
The Animation pull-down menu allows you
to select how you want to display the channel snapshots within each
frame. Setting this to
Slow makes the tool
show channel snapshots in succession, starting at the sample set by
the Sample index slider control. Selecting
the tool show fewer uniformly spaced snapshots, allowing you to go
through the channel snapshots more rapidly. Selecting
only (the default selection) prevents automatic animation
of snapshots within the same frame. The Animation menu
applies to all visualizations except the
Visualization Options. The channel visualization tool plots the characteristics of a filter in various ways. Simply choose the visualization method from the Visualization menu, and the plot updates itself automatically.
The following visualization methods are currently available:Impulse Response (IR)
This plot shows the magnitudes of two impulse responses: the multipath response (infinite bandwidth) and the bandlimited channel response.
The multipath response is represented by stems, each corresponding to one multipath component. The component with the smallest delay value is shown in red, and the component with the largest delay value is shown in blue. Components with intermediate delay values are shades between red and blue, becoming more blue for larger delays.
The bandlimited channel response is represented by the green curve. This response is the result of convolving the multipath impulse response, described above, with a sinc pulse of period, T, equal to the input signal's sample period.
The solid green circles represent the channel filter response sampled at rate 1/T. The output of the channel filter is the convolution of the input signal (sampled at rate 1/T) with this discrete-time FIR channel filter response. For computational speed, the response is truncated.
The hollow green circles represent sample values not captured in the channel filter response that is used for processing the input signal.
Note that these impulse responses vary over time. You can use the slider to visualize how the impulse response changes over time for the current frame (i.e., input signal vector over time).Frequency Response (FR)
This plot shows the magnitude (in dB) of the frequency response of the multipath channel over the signal bandwidth.
As with the impulse response visualization, you can visualize how this frequency response changes over time.IR Waterfall
This plot shows the evolution of the magnitude impulse response over time.
It shows 10 snapshots of the bandlimited channel impulse response within the last frame, with the darkest green curve showing the current response.
The time offset is the time of the channel snapshot relative to the current response time.Phasor Trajectory
This plot shows phasors (vectors representing magnitude and phase) for each multipath component, using the same color code that was used for the impulse response plot.
The phasors are connected end to end in order of path delay, and the trajectory of the resultant phasor is plotted as a green line. This resultant phasor is referred to as the narrowband phasor.
This plot can be used to determine the impact of the multipath channel on a narrowband signal. A narrowband signal is defined here as having a sample period much greater than the span of delays of the multipath channel (alternatively, a signal bandwidth much smaller than the coherence bandwidth of the channel). Thus, the multipath channel can be represented by a single complex gain, which is the sum of all the multipath component gains. When the narrowband phasor trajectory passes through or near the origin, it corresponds to a deep narrowband fade.Multipath Components
This plot shows the magnitudes of the multipath gains over time, using the same color code as that used for the multipath impulse response.
The triangle marker and vertical dashed line represent the start of the current frame. If a frame has been processed previously, its multipath gains may also be displayed.Multipath Gain
This plot shows the collective gains for the multipath channel for three signal bandwidths.
A collective gain is the sum of component magnitudes, as explained in the following:
Narrowband (magenta dots): This is the magnitude of the narrowband phasor in the above trajectory plot. This curve is sometimes referred to as the narrowband fading envelope.
Current signal bandwidth (dashed blue line): This is the sum of the magnitudes of the channel filter impulse response samples (the solid green dots in the impulse response plot). This curve represents the maximum signal energy that can be captured using a RAKE receiver. Its value (or metrics, such as theoretical BER, derived from it) is sometimes referred to as the matched filter bound.
Infinite bandwidth (solid red line): This is the sum of the magnitudes of the multipath component gains.
In general, the variability of this multipath gain, or of the signal fading, decreases as signal bandwidth is increased, because multipath components become more resolvable. If the signal bandwidth curve roughly follows the narrowband curve, you might describe the signal as narrowband. If the signal bandwidth curve roughly follows the infinite bandwidth curve, you might describe the signal as wideband. With the right receiver, a wideband signal exploits the path diversity inherent in a multipath channel.Doppler Spectrum
This plot shows up to two Doppler spectra.
The first Doppler spectrum, represented by the dashed red line, is a theoretical spectrum based on the Doppler filter response used in the multipath channel model. In the preceding plot, the theoretical Doppler spectrum used for the multipath channel model is known as the Jakes spectrum. Note that the plotted Doppler spectrum is normalized to have a total power of 1. This Doppler spectrum is used to determine a Doppler filter response. For practical purposes, the Doppler filter response is truncated, which has the effect of modifying the Doppler spectrum, as shown in the plot.
The second Doppler spectrum, represented by the blue dots, is determined by measuring the power spectrum of the multipath fading channel as the model generates path gains. This measurement is meaningful only after enough path gains have been generated. The title above the plot reports how many samples need to be processed through the channel before either the first Doppler spectrum or an updated spectrum can be plotted.
The Path Number edit box allows you to
visualize the Doppler spectrum of the specified path. The value entered
in this box must be a valid path number, i.e., between 1 and the length
PathDelays vector property. Once you change
the value of this field, the new Doppler spectrum will appear as soon
as the processing of the current frame has ended.
If the measured Doppler spectrum is a good approximation of the theoretical Doppler spectrum, the multipath channel model has generated enough fading gains to yield a reasonable representation of the channel statistics. For instance, if you want to determine the average BER of a communications link with a multipath channel and you want a statistically accurate measure of this average, you may want to ensure that the channel has processed enough samples to yield at least one Doppler spectrum measurement.
It is possible that a multipath channel (e.g., a Rician channel) can have both specular (line-of-sight) and diffuse components. In such a case, the Doppler spectrum would have both a line component and a wideband component. The channel visualization tool only shows the wideband component for the Doppler spectrum.
Unlike other visualizations, the Doppler spectrum visualization does not support animation. Because there is no intraframe data to plot, the visualization tool only updates the channel statistics at the end of each frame and therefore cannot pause in the middle of a frame. If you switch to the Doppler spectrum visualization from a different visualization that is in pause mode, the Pause button is subsequently disabled. Disabling pause avoids interaction problems between the Doppler spectrum visualization and other animation-style visualizations.Scattering Function
This plot shows the Doppler spectra of each path versus the path delays, using the same color code as that used for the multipath impulse response.
The principle of operation of the Scattering Function plot is similar to that of the Doppler Spectrum plot. The main difference is that the Doppler spectra on this plot are not normalized as they are on the Doppler Spectrum plot, in order to better visualize the power delay profile.Composite Plots
Several composite plots are also available. These are chosen by selecting the following from the Visualization pull-down menu:
IR and FR for impulse response
and frequency response plots.
Components and Gain for
multipath components and multipath gain plots.
Components and IR for multipath
components and impulse response plots.
Components, IR, and Phasor for
multipath components, impulse response, and phasor trajectory plots.
Examples of Using the Channel Visualization Tool. Here are two examples that show how you might interact with the GUI.Visualize Samples Within a Frame
This example shows how to visualize samples within a frame through animation. The following lines of code create a Rayleigh channel and open the channel visualization tool:
% Create a fast fading channel h = rayleighchan(1e-4, 100, [0 1.1e-4], [0 0]); h.StoreHistory = 1; % Allow states to be stored y = filter(h, ones(100,1)); % Process samples through channel plot(h); % Open channel visualization tool
After selecting a visualization option and a speed in the Animation menu, move the Sample index slider control all the way to the left and click Resume. The slider control moves by itself during animation. The sample index increments automatically to show which snapshot you are visualizing.
You can also move the slider control and glance through the samples of the frame as you like.Animate Snapshots Across Frames
This example shows how to animate snapshots across frames. The following lines of code call the filter and plot methods within a loop to accomplish this:
Ts = 1e-4; % Sample period (s) fd = 100; % Maximum Doppler shift % Initialize DPSK modulator for M=4 hMod = comm.DPSKModulator(4); % Path delay and gains tau = [0.1 1.2 2.3 6.2 11.3]*Ts; PdB = linspace(0, -10, length(tau)) - length(tau)/20; nTrials = 10000; % Number of trials N = 100; % Number of samples per frame h = rayleighchan(Ts, fd, tau, PdB); % Create channel object h.NormalizePathGains = false; h.ResetBeforeFiltering = false; h.StoreHistory = 1; h % Show channel object % Channel fading simulation for trial = 1:nTrials x = randi([0 3],10000,1); % Random symbols dpskSig = step(hMod, x); % Modulated symbols y = filter(h, dpskSig); % Channel filter plot(h); % Plot channel response % The line below returns control to the command line in case % the GUI is closed while this program is still running if isempty(findobj('name', 'Multipath Channel')), break; end; end
While the animation is running, you can move the slider control and change the sample index (which also makes the animation pause). After clicking Resume, the plot continues to animate.
ResetBeforeFiltering needs to
be set to false so that the state information in the channel is not
reset after the processing of each frame.
Typically, a path gain in a fading channel changes insignificantly over a period of 1/(100fd) seconds, where fd is the maximum Doppler shift. Because this period corresponds to a very large number of bits in many modern wireless data applications, assessing performance over a statistically significant range of fading entails simulating a prohibitively large amount of data. Quasi-static channel modeling provides a more tractable approach, which you can implement using these steps:
Generate a random channel realization using a maximum Doppler shift of 0.
Process some large number of bits.
Compute error statistics.
Repeat these steps many times to produce a distribution of the performance metric.
The example below illustrates the quasi-static channel modeling approach.
M = 4; % DQPSK modulation order hMod = comm.DQPSKModulator; % Create a DPSK modulator hDemod = comm.DQPSKDemodulator; % Create a DPSK demodulator numBits = 10000; % Each trial uses 10000 bits. numTrials = 20; % Number of BER computations % Note: In reality, numTrials would be a large number % to get an accurate estimate of outage probabilities % or packet error rate. % Use 20 here just to make the example run more quickly. % Create Rician channel object. chan = ricianchan; % Static Rician channel chan.KFactor = 3; % Rician K-factor % Because chan.ResetBeforeFiltering is 1 by default, % FILTER resets the channel in each trial below. % Create an AWGNChannel and ErrorRate calculator System object hChan = comm.AWGNChannel('NoiseMethod', 'Signal to noise ratio (SNR)'); hChan.SNR = 20; hErrorCalc = comm.ErrorRate; serVec = zeros(3,numTrials); % Compute error rate once for each independent trial. for n = 1:numTrials reset(hErrorCalc) tx = randi([0 M-1],numBits,1); % Generate random bit stream dpskSig = step(hMod, tx); % DPSK modulate signal fadedSig = filter(chan, dpskSig); % Apply channel effects rxSig = step(hChan,fadedSig); % Add Gaussian noise. rx = step(hDemod,rxSig); % Demodulate. % Compute number of symbol errors. % Ignore first sample because of DPSK initial condition. serVec(:,n) = step(hErrorCalc,tx(2:end),rx(2:end)); end nErrors = serVec(2,:) per = mean(nErrors > 0) % Proportion of packets that had errors
While the example runs, the Command Window displays the growing
list of symbol error counts in the vector
It also displays the packet error rate at the end. The sample output
below shows a final value of
nErrors and omits
intermediate values. Your results might vary because of randomness
in the example.
nErrors = Columns 1 through 9 0 0 0 0 0 0 0 0 0 Columns 10 through 18 0 0 0 0 7 0 0 0 0 Columns 19 through 20 0 216 per = 0.1000
More About the Quasi-Static Technique. As an example to show how the quasi-static channel modeling approach can save computation, consider a wireless local area network (LAN) in which the carrier frequency is 2.4 GHz, mobile speed is 1 m/s, and bit rate is 10 Mb/s. The following expression shows that the channel changes insignificantly over 12,500 bits:
A traditional Monte Carlo approach for computing the error rate of this system would entail simulating thousands of times the number of bits shown above, perhaps tens of millions of bits. By contrast, a quasi-static channel modeling approach would simulate a few packets at each of about 100 locations to arrive at a spatial distribution of error rates. From this distribution one could determine, for example, how reliable the communication link is for a random location within the indoor space. If each simulation contains 5,000 bits, 100 simulations would process half a million bits in total. This is substantially fewer bits compared to the traditional Monte Carlo approach.