Documentation Center

  • Trial Software
  • Product Updates

Contents

comm.AWGNChannel System object

Package: comm

Add white Gaussian noise to input signal

Description

The AWGNChannel object adds white Gaussian noise to a real or complex input signal. When the input uses a real-valued signal, this object adds real Gaussian noise and produces a real output signal. When the input uses a complex signal, this object adds complex Gaussian noise and produces a complex output signal.

When the inputs to the object have a variable number of channels, the EbNo, EsNo, SNR, BitsPerSymbol, SignalPower, SamplesPerSymbol, and Variance properties must be scalars, when applicable.

To add white Gaussian noise to an input signal:

  1. Define and set up your additive white Gaussian noise channel object. See Construction.

  2. Call step to add white Gaussian noise to the input signal according to the properties of comm.AWGNChannel. The behavior of step is specific to each object in the toolbox.

Construction

H = comm.AWGNChannel creates an additive white Gaussian noise (AWGN) channel System object™, H. This object then adds white Gaussian noise to a real or complex input signal.

H = comm.AWGNChannel(Name,Value) creates an AWGN channel object, H, with each specified property set to the specified value. You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

Properties

NoiseMethod

Method to specify noise level

Select the method to specify the noise level as one of Signal to noise ratio (Eb/No) | Signal to noise ratio (Es/No)| Signal to noise ratio (SNR) | Variance. The default is Signal to noise ratio (Eb/No).

EbNo

Energy per bit to noise power spectral density ratio (Eb/No)

Specify the Eb/No ratio in decibels. You can set this property to a numeric, real scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Signal to noise ratio (Eb/No). The default is 10. This property is tunable.

EsNo

Energy per symbol to noise power spectral density ratio (Es/No)

Specify the Es/No ratio in decibels. You can set this property to a numeric, real scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Signal to noise ratio (Es/No). The default is 10. This property is tunable.

SNR

Signal to noise ratio (SNR)

Specify the SNR value in decibels. You can set this property to a numeric, real scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Signal to noise ratio (SNR). The default is 10. This property is tunable.

BitsPerSymbol

Number of bits in one symbol

Specify the number of bits in each input symbol. You can set this property to a numeric, positive, integer scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Signal to noise ratio (Eb/No). The default is 1 bit.

SignalPower

Input signal power in Watts

Specify the mean square power of the input signal in Watts. You can set this property to a numeric, positive, real scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Signal to noise ratio (Eb/No), Signal to noise ratio (Es/No), or Signal to noise ratio (SNR). The default is 1. The object assumes a nominal impedance of 1 Ω. This property is tunable.

SamplesPerSymbol

Number of samples per symbol

Specify the number of samples per symbol. You can set this property to a numeric, positive, integer scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Signal to noise ratio (Eb/No) or Signal to noise ratio (Es/No). The default is 1.

VarianceSource

Source of noise variance

Specify the source of the noise variance as one of Property | Input port. The default is Property. Set this property to Input port to specify the noise variance value using an input to the step method. Set this property to Property to specify the noise variance value using the Variance property. This property applies when you set the NoiseMethod property to Variance.

Variance

Noise variance

Specify the variance of the white Gaussian noise. You can set this property to a numeric, positive, real scalar or row vector with a length equal to the number of channels. This property applies when you set the NoiseMethod property to Variance and the VarianceSource property to Property. The default is 1. This property is tunable.

RandomStream

Source of random number stream

Specify the source of random number stream as one of Global stream | mt19937ar with seed. The default value of this property is Global stream.

When you set this property to Global stream, the object uses the current global random number stream for normally distributed random number generation.

When you set this property to mt19937ar with seed, the object uses the mt19937ar algorithm for normally distributed random number generation. In this scenario, when you call the reset method, the object re-initializes the random number stream to the value of the Seed property.

Seed

Initial seed of mt19937ar random number stream

Specify the initial seed of a mt19937ar random number generator algorithm as a double-precision, real, nonnegative integer scalar. The default value of this property is 67.

This property applies when you set the RandomStream property to mt19937ar with seed. For each call to the reset method, the object re-initialize the mt19937ar random number stream to the Seed value.

Methods

cloneCreate AWGN channel object with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
releaseAllow property value and input characteristics changes
resetReset states of the AWGNChannel System object
stepAdd white Gaussian noise to input signal

Examples

expand all

Add White Gaussian noise to an 8-PSK signal

Modulate an 8–PSK signal, add White Gaussian noise, and plot the signal to observe the effects of noise. Then, compare the results to a multi-channel response.

Create a PSK Modulator System object.

hMod = comm.PSKModulator;

Modulate the signal by calling the step method of the PSK modulator.

modData = step(hMod, randi([0 hMod.ModulationOrder-1], 1000, 1));

Add White Gaussian noise to the modulated signal by passing the signal through an AWGN channel.

hAWGN = comm.AWGNChannel('EbNo', 15, ...
'BitsPerSymbol', log2(hMod.ModulationOrder));

Transmit the signal through the AWGN channel by call the step method of the AWGN channel.

channelOutput = step(hAWGN, modData);

Plot the noiseless and noisy data using scatter plots to observe the effects of noise.

scatterplot(modData)
scatterplot(channelOutput)

Use a multi-channel input with greater noise by setting the EbNo value to 10.

hAWGN.EbNo = 10;

Modulate the signal by calling the step method.

modData = step(hMod, randi([0 hMod.ModulationOrder-1], 1000, 1));
modData = reshape(modData, 500, 2);

Obtain the signal at the output of the channel by calling the step method.

channelOutput = step(hAWGN, modData);

Plot the channel output to see the effects that the noise has on the signal.

scatterplot(channelOutput(:))

Process two consecutive inputs with different numbers of samples

Create the AWGN System object with the EbNo ratio set to a 1–by–2 vector by typing the following syntax at the MATLAB® command line.

h = comm.AWGNChannel('EbNo', [10 5]);

Process the first input signal by calling the step method. This object processes 128 samples per channel over two channels.

step(h, ones(128, 2));

Process the second input signal by calling the step method. Without being released, this object processes an additional 256 samples per channel over two channels.

step(h, ones(256, 2))

In this example, the number of samples each channels processes can change. Because the number of channels remains fixed, you can specify the EbNo property value as a vector.

Process two consecutive inputs with different numbers of samples and channels

This example shows how the value of a tunable property can change between two inputs of different sizes, as long as the input is a scalar.

Create an AWGN Channel System object, with the NoiseMethod property set to Signal to noise ratio and the SNR property value to 20.

h = comm.AWGNChannel( ... 
    'NoiseMethod', 'Signal to noise ratio (SNR)',...
    'SNR', 20);

Process the first input signal by calling the step method. The input has one channel.

step(h, ones(20, 1));

Process the second input signal by calling the step method. The input has two channels, and a different number of samples per channel.

step(h, ones(90, 2))

In this example, the number of channels can change, but the SNR property value must be a scalar.

Process signals with a noise variance input

This example shows the noise variance input as a scalar or a row vector, with a length equal to the number of channels of the current signal input.

Create an AWGN Channel System object, with the NoiseMethod property set to Variance and the VarianceSource property set to Input port.

h = comm.AWGNChannel( ... 
    'NoiseMethod',    'Variance', ... 
    'VarianceSource', 'Input port');

Process the data by calling the step method. The object processes 128 samples through two channels. The variance input is a 1–by–2 vector.

step(h, ones(128, 2), [0.1, 0.2]);

Process the data by calling the step method. The object processes 150 samples through five channels. The variance input is a scalar.

step(h, ones(150, 5), 1)

Process signals using a self-contained random stream for repeatability

This example shows how to produce the same outputs, after reset, when using a self-contained random stream.

Create an AWGN Channel System object. Set the NoiseMethod property to Variance, the RandomStream property to mt19937ar with seed, and the Seed property to 99.

h = comm.AWGNChannel( ... 
    'NoiseMethod',  'Variance', ... 
    'RandomStream', 'mt19937ar with seed', ... 
    'Seed',          99);

Process the data by calling the step method.

y1 = step(h, ones(8, 2));

Reset the AWGN Channel System object by calling the reset method. This resets the random data stream to the initial seed of 99.

reset(h);

Process the same data by calling the step method.

y2 = step(h, ones(8, 2));

Compare the two signals.

isequal(y1, y2)

Algorithms

This object implements the algorithm, inputs, and outputs described on the AWGN Channel block reference page. The object properties correspond to the block parameters, except for:

  • The block uses a random number generator based on the V5 RANDN (Ziggurat) algorithm and an initial seed, set with the Initial seed parameter to initialize the random number generator. Every time the system that contains the block is run, the block generates the same sequence of random numbers. Similarly, on the object, when you set the RandomStream property to mt19937ar with seed, you can generate reproducible numbers by resetting the object.

    When you set the RandomStream property to Global stream, this object uses the MATLAB default random stream to generate random numbers. To generate reproducible numbers using this object, you can reset the MATLAB default random stream using the following code.

    reset(RandStream.getGlobalStream)

    For more information, see help for RandStream.

  • Sometimes, the input to the step method is complex. In such cases, if you try to match the block and object's random generator and seed by setting the random stream of MATLAB, the random numbers do not appear in the same order.

    The object creates the random data as follows:

    noise = randn(lengthInput,1) + 1i randn(lengthInput,1)

    The block creates random data as follows:

    randData = randn(2 lengthInput,1)
    noise = randData(1:2:end) + 1i randData(2:2:end)

  • The Symbol period block parameter corresponds to the SamplesPerSymbol property.

  • The Variance from mask and Variance from port block parameter options of the Mode parameter correspond to the VarianceSource property.

See Also

Was this topic helpful?