Main Content

comm.AWGNChannel

Add white Gaussian noise to input signal

Description

comm.AWGNChannel adds white Gaussian noise to the input signal.

When applicable, if inputs to the object have a variable number of channels, theEbNo,EsNo,SNR,BitsPerSymbol,SignalPower,SamplesPerSymbol, andVarianceproperties must be scalars.

To add white Gaussian noise to an input signal:

  1. Create thecomm.AWGNChannelobject and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, seeWhat Are System Objects?

Creation

Description

example

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

example

awgnchan= comm.AWGNChannel(Name,Value)创建一个美国线规N channel object,awgnchan, with the specified propertyNameset to the specifiedValue。You can specify additional name-value pair arguments in any order as (Name1,Value1,...,NameN,ValueN).

Properties

expand all

Unless otherwise indicated, properties arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

If a property istunable, you can change its value at any time.

For more information on changing property values, seeSystem Design in MATLAB Using System Objects

Noise level method, specified as'Signal to noise ratio (Eb/No)','Signal to noise ratio (Es/No)','Signal to noise ratio (SNR)', or'Variance'。For more information, seeSpecifying the Variance Directly or Indirectly

Data Types:char

Ratio of energy per bit to noise power spectral density (Eb/No) in decibels, specified as a scalar or 1-by-NCvector.NCis the number of channels.

Tunable:Yes

Dependencies

This property applies whenNoiseMethodis set to'Signal to noise ratio (Eb/No)'

Data Types:double

Ratio of energy per symbol to noise power spectral density (Es/No) in decibels, specified as a scalar or 1-by-NCvector.NCis the number of channels.

Tunable:Yes

Dependencies

This property applies whenNoiseMethodis set to'Signal to noise ratio (Es/No)'

Data Types:double

Ratio of signal power to noise power in decibels, specified as a scalar or 1-by-NCvector.NCis the number of channels.

Tunable:Yes

Dependencies

This property applies whenNoiseMethodis set to'Signal to noise ratio (SNR)'

Data Types:double

Number of bits per symbol, specified as a positive integer.

Dependencies

This property applies whenNoiseMethodis set to'Signal to noise ratio (Eb/No)'

Data Types:double

Input signal power in watts, specified as a positive scalar or 1-by-NCvector.NCis the number of channels. The object assumes a nominal impedance of 1 Ω.

Tunable:Yes

Dependencies

This property applies whenNoiseMethodis set to'Signal to noise ratio (Eb/No)','Signal to noise ratio (Es/No)', or'Signal to noise ratio (SNR)'

Data Types:double

Number of samples per symbol, specified as a positive integer or 1-by-NCvector.NCis the number of channels.

Dependencies

This property applies whenNoiseMethodis set to'Signal to noise ratio (Eb/No)'or'Signal to noise ratio (Es/No)'

Data Types:double

Source of noise variance, specified as'Property'or'Input port'

  • SetVarianceSourceto'Property'to specify the noise variance value using theVarianceproperty.

  • SetVarianceSourceto'Input port'to specify the noise variance value using an input to the object, when you call it as a function.

For more information, seeSpecifying the Variance Directly or Indirectly

Dependencies

This property applies whenNoiseMethodis'Variance'

Data Types:char

White Gaussian noise variance, specified as a positive scalar or 1-by-NCvector.NCis the number of channels.

Tunable:Yes

Dependencies

This property applies whenNoiseMethodis set to'Variance'andVarianceSourceis set to'Property'

Data Types:double

Source of random number stream, specified as'Global stream'or'mt19937ar with seed'

  • When you setRandomStreamto'Global stream',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. For examplereset(RandStream.getGlobalStream)。For more information, seeRandStream

  • When you setRandomStreamto'mt19937ar with seed',object uses the mt19937ar algorithm for normally distributed random number generation. In this scenario, when you call theresetfunction, the object reinitializes the random number stream to the value of theSeedproperty. You can generate reproducible numbers by resetting the object.

For a complex input signal, the object creates the random data as follows:

noise=randn(NS,NC)+1i(randn(NS,NC))
N Sis the number of samples andN Cis the number of channels.

Dependencies

This property applies whenNoiseMethodis set to'Variance'

Data Types:char

Initial seed of the mt19937ar random number stream, specified as a nonnegative integer. For each call to theresetfunction, the object reinitializes the mt19937ar random number stream to theSeedvalue.

Dependencies

This property applies whenRandomStreamis set to'mt19937ar with seed'

Data Types:double

Usage

Description

example

outsignal= awgnchan(insignal)adds white Gaussian noise, as specified byawgnchan, to the input signal. The result is returned inoutsignal

example

outsignal= awgnchan(insignal,var)specifies the variance of the white Gaussian noise. This syntax applies when you set theNoiseMethodto'Variance'andVarianceSourceto'Input port'

For example:

awgnchan = comm.AWGNChannel('NoiseMethod','Variance', ... 'VarianceSource','Input port'); var = 12; ... outsignal = awgnchan(insignal,var);

Input Arguments

expand all

Input signal, specified as a scalar, anNS-element vector, or anNS-by-NC矩阵。NSis the number of samples andNCis the number of channels.

Data Types:double
Complex Number Support:Yes

Variance of additive white Gaussian noise, specified as a positive scalar or 1-by-NCvector.NCis the number of channels, as determined by the number of columns in the input signal matrix.

Output Arguments

expand all

Output signal, returned with the same dimensions asinsignal

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object namedobj, use this syntax:

release(obj)

expand all

step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem object

Examples

collapse all

Create an AWGN channel System object with the default configuration. Pass signal data through this channel.

Create an AWGN channel object and signal data.

awgnchan = comm.AWGNChannel; insignal = randi([0 1],100,1);

Send the input signal through the channel.

outsignal = awgnchan(insignal);

Modulate an 8-PSK signal, add white Gaussian noise, and plot the signal to visualize the effects of the noise.

Create a M-PSK modulator System object™. The default modulation order for the object is 8.

pskModulator = comm.PSKModulator;

Modulate the signal.

modData = pskModulator(randi([0 7],2000,1));

添加高斯白噪声调制信号by passing the signal through an additive white Gaussian noise (AWGN) channel.

channel = comm.AWGNChannel('EbNo',20,'BitsPerSymbol',3);

Transmit the signal through the AWGN channel.

channelOutput = channel(modData);

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

scatterplot(modData)

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

scatterplot(channelOutput)

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

Change theEbNoproperty to 10 dB to increase the noise.

channel.EbNo = 10;

Pass the modulated data through the AWGN channel.

channelOutput = channel(modData);

Plot the channel output. You can see the effects of increased noise.

scatterplot(channelOutput)

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

Pass a single-channel and multichannel signal through an AWGN channel System object™.

Create an AWGN channel System object with the Eb/No ratio set for a single channel input. In this case, theEbNoproperty is a scalar.

channel = comm.AWGNChannel('EbNo',15);

Generate random data and apply QPSK modulation.

data = randi([0 3],1000,1); modData = pskmod(data,4,pi/4);

Pass the modulated data through the AWGN channel.

rxSig = channel(modData);

Plot the noisy constellation.

scatterplot(rxSig)

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

Generate two-channel input data and apply QPSK modulation.

data = randi([0 3],2000,2); modData = pskmod(data,4,pi/4);

Pass the modulated data through the AWGN channel.

rxSig = channel(modData);

Plot the noisy constellations. Each channel is represented as a single column inrxSig。The plots are nearly identical, because the same Eb/No value is applied to both channels.

scatterplot(rxSig(:,1)) title('First Channel')

图散点图包含一个坐标轴对象。的一个xes object with title First Channel contains an object of type line. This object represents Channel 1.

scatterplot(rxSig(:,2)) title('Second Channel')

图散点图包含一个坐标轴对象。的一个xes object with title Second Channel contains an object of type line. This object represents Channel 1.

Modify the AWGN channel object to apply a different Eb/No value to each channel. To apply different values, set theEbNoproperty to a 1-by-2 vector. When changing the dimension of theEbNoproperty, you must release the AWGN channel object.

release(channel) channel.EbNo = [10 20];

Pass the data through the AWGN channel.

rxSig = channel(modData);

Plot the noisy constellations. The first channel has significantly more noise due to its lower Eb/No value.

scatterplot(rxSig(:,1)) title('First Channel')

图散点图包含一个坐标轴对象。的一个xes object with title First Channel contains an object of type line. This object represents Channel 1.

scatterplot(rxSig(:,2)) title('Second Channel')

图散点图包含一个坐标轴对象。的一个xes object with title Second Channel contains an object of type line. This object represents Channel 1.

Apply 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 theNoiseMethodproperty set to 'Variance'and theVarianceSourceproperty set to 'Input port'

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

Generate random data for two channels and apply 16-QAM modulation.

data = randi([0 15],10000,2); txSig = qammod(data,16);

Pass the modulated data through the AWGN channel. The AWGN channel object processes data from two channels. The variance input is a 1-by-2 vector.

rxSig = channel(txSig,[0.01 0.1]);

Plot the constellation diagrams for the two channels. The second signal is noisier because its variance is ten times larger.

scatterplot(rxSig(:,1))

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

scatterplot(rxSig(:,2))

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

Repeat the process where the noise variance input is a scalar. The same variance is applied to both channels. The constellation diagrams are nearly identical.

rxSig = channel(txSig,0.2); scatterplot(rxSig(:,1))

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

scatterplot(rxSig(:,2))

图散点图包含一个坐标轴对象。的一个xes object with title Scatter plot contains an object of type line. This object represents Channel 1.

Specify a seed to produce the same outputs when using a random stream in which you specify the seed.

Create an AWGN channel System object™. Set theNoiseMethodproperty to'Variance',RandomStreamproperty to'mt19937ar with seed', and theSeedproperty to99

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

Pass data through the AWGN channel.

y1 = channel(zeros(8,1));

Pass another all-zeros vector through the channel.

y2 = channel(zeros(8,1));

Because the seed changes between function calls, the output is different.

isequal(y1,y2)
ans =logical0

Reset the AWGN channel object by calling theresetfunction. The random data stream is reset to the initial seed of99

reset(channel);

Pass the all-zeros vector through the AWGN channel.

y3 = channel(zeros(8,1));

Confirm that the two signals are identical.

isequal(y1,y3)
ans =logical1

Algorithms

expand all

References

[1] Proakis, John G.Digital Communications。四。麦格劳-希尔,2001年。

Extended Capabilities

Version History

Introduced in R2012a