Add white Gaussian noise to signal
adds white Gaussian noise to the vector signal
Y = awgn(
X. This syntax
assumes that the power of
X is 0 dBW. For more information about additive
white Gaussian noise, see What is AWGN?
accepts an input signal power value in dBW. To measure the power of
Y = awgn(
X before adding
'measured' option does not generate the
requested average SNR for repeated
awgn function calls in a loop if the
input signal power varies over time due to fading and the coherence time of the channel is
larger than the input duration.
additionally accepts a random number stream object to generate normal random noise samples. For
information about producing repeatable noise samples, see Tips.
Y = awgn(
specifies a seed value for initializing the normal random number generator that is used to add
white Gaussian noise to the input signal.
Y = awgn(
specifies the signal and noise power type as
Y = awgn(___,
'linear' in addition to the input arguments in any of the previous
syntaxes. For information on the relationships between SNR and other measures of the relative
power of the noise, such as
AWGN Channel Noise Level.
Add AWGN to Sawtooth Signal
Create a sawtooth wave.
t = (0:0.1:60)'; x = sawtooth(t);
Add white Gaussian noise and plot the results.
y = awgn(x,10,'measured'); plot(t,[x y]) legend('Original Signal','Signal with AWGN')
Estimate Symbol Rate for General QAM Modulation in AWGN Channel
Transmit and receive data using a nonrectangular 16-ary constellation in the presence of Gaussian noise. Show the scatter plot of the noisy constellation and estimate the symbol error rate (SER) for two different SNRs.
Create a 16-QAM constellation based on the V.29 standard for telephone-line modems.
c = [-5 -5i 5 5i -3 -3-3i -3i 3-3i 3 3+3i 3i -3+3i -1 -1i 1 1i]; sigpower = pow2db(mean(abs(c).^2)); M = length(c);
Generate random symbols.
data = randi([0 M-1],2000,1);
Modulate the data by using the
genqammod function. General QAM modulation is necessary because the custom constellation is not rectangular.
modData = genqammod(data,c);
Pass the signal through an AWGN channel with a 20 dB SNR.
rxSig = awgn(modData,20,sigpower);
Display a scatter plot of the received signal and the reference constellation
h = scatterplot(rxSig); hold on scatterplot(c,,,'r*',h) grid hold off
Demodulate the received signal by using the
genqamdemod function. Determine the number of symbol errors and the SER.
demodData = genqamdemod(rxSig,c); [numErrors,ser] = symerr(data,demodData)
numErrors = 1
ser = 5.0000e-04
Repeat the transmission and demodulation process with an AWGN channel with a 10 dB SNR. Determine the SER for the reduced SNR. As expected, the performance degrades when the SNR is decreased.
rxSig = awgn(modData,10,sigpower); demodData = genqamdemod(rxSig,c); [numErrors,ser] = symerr(data,demodData)
numErrors = 461
ser = 0.2305
Repeatable AWGN Simulation
Generate random data symbols and the 4-PSK modulated signal.
M = 4; k = log2(M); snr = 3; data = randi([0 M-1],2000,1); x = pskmod(data,M);
Set the random number generator seed.
seed = 12345;
Generate repeatable random noise using the
rng function before calling the
rng(seed); y = awgn(x,snr);
Compute the bit errors.
dataHat = pskdemod(y,M); numErr1 = biterr(data,dataHat,k)
numErr1 = 321
Reset the random number generator seed.
Demodulate the PSK signal and compute the bit errors.
y = awgn(x,snr); dataHat = pskdemod(y,M); numErr2 = biterr(data,dataHat,k)
numErr2 = 321
numErr2. The errors are equal even after you reset the random number generator seed.
ans = logical 1
Repeatable AWGN with RandStream
Generate white Gaussian noise addition results by using a
RandStream object and the
reset object function.
Specify the input signal power of as
0 dBW, add noise to produce an SNR of
10 dB, and use a local random stream. Add white Gaussian noise to
sigin two times to produce
isequal to compare
sigout2. The outputs are not equal when you do not reset the random stream.
S = RandStream('mt19937ar',Seed=5489); sigin = sqrt(2)*sin(0:pi/8:6*pi); sigout1 = awgn(sigin,10,0,S); sigout2 = awgn(sigin,10,0,S); isequal(sigout1,sigout2)
ans = logical 0
Reset the random stream object, returning the object to its state prior to adding AWGN to
sigout1. Add AWGN to
sigin to produce
sigout3, and then compare
sigout3. The outputs are equal when you reset the random stream.
reset(S); sigout3 = awgn(sigin,10,0,S); isequal(sigout1,sigout3)
ans = logical 1
X — Input signal
scalar | vector | array
Input signal, specified as a scalar, vector, or array. The power of the input signal is assumed to be 0 dBW.
Complex Number Support: Yes
snr — Signal-to-noise ratio
Signal-to-noise ratio in dB, specified as a scalar. The function applies the same
snr value to each channel. The columns of the input signal represent the
different channels of a multichannel signal.
signalpower — Signal power
Signal power in dBW, specified as a scalar or
If the input signal is a multichannel signal, the function calculates the
signalpower value across all channels as a single value. It then uses
the value to calculate the noise level for all the channels.
randobject — Random number stream object
Random number stream object, specified as a
RandStream object. The state of the random stream object determines the sequence
of numbers produced by the
randn function. Configure the random stream object
reset (RandStream) function and its
For information about producing repeatable noise samples, see Tips.
seed — Random number generator seed
Random number generator seed value, specified as a scalar.
powertype — Signal power unit
'dB' (default) |
Signal power unit, specified as
snris measured in dB and
signalpoweris measured in dBW.
snris measured as a ratio and
signalpoweris measured in watts assuming a reference load of 1 ohms.
To set the
powertype argument, you must also set
Y — Output signal
scalar | vector | array
Output signal, returned as a scalar, vector, or array. The returned output signal is the input signal with added white Gaussian noise.
var — Noise variance
Total noise variance, returned as a positive scalar. The function uses the noise variance to generate random noise samples.
What is AWGN?
Additive white Gaussian noise (AWGN) is a simple noise model that represents electron motion in the RF front end of a receiver. As the name implies, the noise gets added to the signal. The noise is called white because it is spectrally flat across the entire sampling bandwidth. Analogously, the color white contains equal spectral power levels at all frequencies of the visible light spectrum. The noise is Gaussian because its amplitude can be modeled with a normal probability distribution.
The AWGN channel is often used to model a satellite communications channel, since that channel typically does not suffer from common terrestrial impairments like fading, multipath, and interference. An AGWN channel serves as a good starting point for the analysis of terrestrial wireless links because it establishes a best-case bound on the bit error rate performance of a terrestrial link.
For information on the relationships between SNR and other measures of the relative power of the noise, such as Es/N0, and Eb/N0, see AWGN Channel Noise Level.
To generate repeatable white Gaussian noise samples, do one of the following:
seed) before calling the
awgnfunction to generate repeatable random noise.
Provide a static
seedvalue as an input to
reset (RandStream)function on the
randobjectbefore passing it as an input to
randobjectin a known state as an input to
awgn. For more information, see
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
Code generation supported, except for syntaxes that include a
Introduced before R2006a