Add white Gaussian noise to signal
Create a sawtooth wave.
t = (0:0.1:10)'; x = sawtooth(t);
Apply white Gaussian noise and plot the results.
y = awgn(x,10,'measured'); plot(t,[x y]) legend('Original Signal','Signal with AWGN')
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 signal-to-noise ratios.
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]; 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 having a 20 dB signal-to-noise ratio (SNR).
rxSig = awgn(modData,20,'measured');
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 symbol error ratio.
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 having a 10 dB SNR. Determine the symbol error rate for the reduced SNR. As expected, the performance degrades when the SNR is decreased.
rxSig = awgn(modData,10,'measured'); demodData = genqamdemod(rxSig,c); [numErrors,ser] = symerr(data,demodData)
numErrors = 462
ser = 0.2310
Specify the power of X to be
0 dBW, add noise to produce an SNR of
10 dB, and utilize a local random stream.
S = RandStream('mt19937ar','Seed',5489); sigin = sqrt(2)*sin(0:pi/8:6*pi); sigout1 = awgn(sigin,10,0,S);
Add AWGN to
isequal to compare
sigout2. The outputs are not equal when the random stream was not reset.
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 and compare
sigout3. The outputs are equal after the random stream was reset.
reset(S); sigout3 = awgn(sigin,10,0,S); isequal(sigout1,sigout3)
ans = logical 1
in— Input signal
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.
When the noise is added, this function applies the same
snr to all
elements of the full input signal. Array input signals do not have a notion of independent
channels. To consider multiple channels independently, see
signalpower— Signal power
Signal power, specified as a scalar or
'measured', the signal
in is computed to determine the appropriate noise level based
on the value of
When you specify
'measured', this function computes the signal
power using all elements of the full input signal. When the power is computed, array
input signals do not have a notion of independent 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
Signal power unit, specified as
For 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.
out— Output signal
Output signal, returned as a scalar, vector, or array. The returned output signal is the input signal with white Gaussian noise added to it.
To generate repeatable white Gaussian noise samples, use one of these tips:
Usage notes and limitations:
Code generation supported, except for syntaxes that include a