AWGN Channel
Add white Gaussian noise to input signal
Libraries:
Communications Toolbox /
Channels
Description
The AWGN Channel block adds white Gaussian noise to the input signal. It inherits the sample time from the input signal.
Examples
Using AWGN Channel Block for Coded Signals
When your simulation uses coding, the Eb/N0 setting for the AWGN channel must be adjusted by the coding rate to apply the desired signal to noise (SNR) ratio.
The slex_hamming_check.slx
model performs forward error control (FEC) coding on a BPSKmodulated signal that gets filtered through an AWGN channel. The model uses BPSK Modulator Baseband, AWGN Channel, and BPSK Demodulator Baseband discrete blocks to simulate a binary symmetric channel. To account for difference between the coded and uncoded Eb/N0 (Eb/N0), the AWGN channel block computes the coded Eb/N0 as Eb/N0 + 10log10(K/N) dB, where K/N is the code rate and Eb/N0 is the uncoded Eb/N0. The Hamming Encoder block has an input bit period of 1 second and the output bit period decreases, by a factor of the K/N code rate, to 4/7 seconds. Due to the coding rate, the Binary Symmetric Channel has a bit period of 4/7 seconds.
The model initializes variables used to configure block parameters by using the PreLoadFcn
callback function. For more information, see Model Callbacks (Simulink).
model = 'slex_hamming_check';
open_system(model);
The AWGN channel block must also configure the Number of bits per symbol and Input signal power, referenced to 1 ohm (watts) parameter settings based on the modulated signal. This example uses BPSK modulation, so the AWGN Channel block has number of bits per symbol set to 1
. The model includes a Power Meter block that measures the signal power at the AWGN input to confirm the setting required for the input signal power of the AWGN Channel block.
Produce error rate results and a plot to compare simulation with theory. The theoretical channel error probability for the coded signal is Q(sqrt(2*Ebc/N0)), where Q() is the standard Q function and Ebc/N0 is the coded Eb/N0 in linear units (not in dB). Compute the theoretical BER upper limit bound of a linear, rate 4/7 block code with a minimum distance of 3, and hard decision decoding for a BPSKmodulated signal in AWGN over a range of Eb/N0 values by using the
function. Simulate the bercoding
slex_hamming_check
model over the same range of Eb/N0 values.
EbNoVec = 0:2:10; theorBER = bercoding(EbNoVec,'block','hard',7,4,3); berVecBSC = zeros(length(EbNoVec),3); for n = 1:length(EbNoVec) EbNo = EbNoVec(n); sim(model); berVecBSC(n,:) = berBSC(end,1); end
Plot the results by using the semilogy
function to show the nearly identical results. The model has the Error Rate Calculation block configured to run each Eb/N0 point until 200 errors occur or the block receives 1x10^6 bits.
semilogy( ... EbNoVec,berVecBSC(:,1),'d', ... EbNoVec,theorBER,''); legend('BSC BER','Theoretical BER', ... Location="southwest"); xlabel("Eb/N0 (dB)"); ylabel("Error Probability"); title("Bit Error Probability"); grid on;
LLR vs. Hard Decision Demodulation in Simulink
This model shows the improvement in BER performance when using loglikelihood ratio (LLR) instead of hard decision demodulation in a convolutionally coded communication link.
For a MATLAB® version of this example, see LogLikelihood Ratio (LLR) Demodulation.
System Setup
This example model simulates a convolutionally coded communication system having one transmitter, an AWGN channel and three receivers. The convolutional encoder has a code rate of 1/2. The system employs a 16QAM modulation. The modulated signal passes through an additive white Gaussian noise channel. The top receiver performs hard decision demodulation in conjunction with a Viterbi decoder that is set up to perform hard decision decoding. The second receiver has the demodulator configured to compute loglikelihood ratios (LLRs) that are then quantized using a 3bit quantizer. It is well known that the quantization levels are dependent on noise variance for optimum performance [2]. The exact boundaries of the quantizer are empirically determined here. A Viterbi decoder that is set up for soft decision decoding processes these quantized values. The LLR values computed by the demodulator are multiplied by 1 to map them to the right quantizer index for use with Viterbi Decoder. To compute the LLR, the demodulator must be given the variance of noise as seen at its input. The third receiver includes a demodulator that computes LLRs which are processed by a Viterbi decoder that is set up in unquantized mode. The BER performance of each receiver is computed and displayed.
modelName = 'commLLRvsHD';
open_system(modelName);
System Simulation and Visualization
Simulate this system over a range of information bit Eb/No values. Adjust these Eb/No values for coded bits and multibit symbols to get noise variance values required for the AWGN block and Rectangular QAM Baseband Demodulator block. Collect BER results for each Eb/No value and visualize the results.
EbNo = 2:0.5:8; % information rate Eb/No in dB codeRate = 1/2; % code rate of convolutional encoder nBits = 4; % number of bits in a 16QAM symbol Pavg = 10; % average signal power of a 16QAM modulated signal snr = EbNo  10*log10(1/codeRate) + 10*log10(nBits); % SNR in dB noiseVarVector = Pavg ./ (10.^(snr./10)); % noise variance % Initialize variables for storing the BER results ber_HD = zeros(1,length(EbNo)); ber_SD = zeros(1,length(EbNo)); ber_LLR = zeros(1, length(EbNo)); % Loop over all noiseVarVector values for idx=1:length(noiseVarVector) noiseVar = noiseVarVector(idx); %#ok<NASGU> sim(modelName); % Collect BER results ber_HD(idx) = BER_HD(1); ber_SD(idx) = BER_SD(1); ber_LLR(idx) = BER_LLR(1); end % Perform curve fitting and plot the results fitBER_HD = real(berfit(EbNo,ber_HD)); fitBER_SD = real(berfit(EbNo,ber_SD)); fitBER_LLR = real(berfit(EbNo,ber_LLR)); semilogy(EbNo,ber_HD,'r*', ... EbNo,ber_SD,'g*', ... EbNo,ber_LLR,'b*', ... EbNo,fitBER_HD,'r', ... EbNo,fitBER_SD,'g', ... EbNo,fitBER_LLR,'b'); legend('Hard Decision Decoding', ... 'Soft Decision Decoding','Unquantized Decoding'); xlabel('Eb/No (dB)'); ylabel('BER'); title('LLR vs. Hard Decision Demodulation with Viterbi Decoding'); grid on;
To experiment with this system further, try different modulation types. This system uses a binary mapped modulation scheme for faster error collection but it is well known that Gray mapped signal constellation provides better BER performance. Experiment with various constellation ordering options in the modulator and demodulator blocks. Configure the demodulator block to compute approximate LLR to see the difference in the BER performance compared to hard decision demodulation and LLR. Try out a different range of Eb/No values. Finally, investigate different quantizer boundaries for your modulation scheme and Eb/No values.
Using Dataflow in Simulink
You can configure this example to use datadriven execution by setting the Domain parameter to dataflow for Dataflow Subsystem. With dataflow, blocks inside the domain, execute based on the availability of data as rather than the sample timing in Simulink®. Simulink automatically partitions the system into concurrent threads. This autopartitioning accelerates simulation and increases data throughput. To learn more about dataflow and how to run this example using multiple threads, see Multicore Simulation of Comparing Demodulation Types.
% Cleanup close_system(modelName,0); clear modelName EbNo codeRate nBits Pavg snr noiseVarVector ... ber_HD ber_SD ber_LLR idx noiseVar fitBER_HD fitBER_SD fitBER_LLR;
Selected Bibliography
[1] J. L. Massey, "Coding and Modulation in Digital Communications", Proc. Int. Zurich Seminar on Digital Communications, 1974
[2] J. A. Heller, I. M. Jacobs, "Viterbi Decoding for Satellite and Space Communication", IEEE® Trans. Comm. Tech. vol COM19, October 1971
GrayCoded MPSK Modulation Error Rate in AWGN Channel Using Simulink
This example uses the doc_gray_code
to compute bit error rates (BER) and symbol error rates (SER) for MPSK modulation. The theoretical error rate performance of MPSK modulation in AWGN is compared to the error rate performance for Graycoded symbol mapping and to the error rate performance of binarycoded symbol mapping.
The Random Integer Generator block serves as the source, producing a sequence of integers. The Integer to Bit Converter block converts each integer into a corresponding binary representation. The MPSK Modulator Baseband block in the doc_gray_code
model:
Accepts binaryvalued inputs that represent integers in the range [0, (M  1], where M is the modulation order.
Maps binary representations to constellation points using a Graycoded ordering.
Produces unitmagnitude complex phasor outputs, with evenly spaced phases in the range [0, (2 (M  1) / M)].
The AWGN Channel block adds white Gaussian noise to the modulated data. The MPSK Demodulator Baseband block demodulates the noisy data. The Bit to Integer Converter block converts each binary representation to a corresponding integer. Then two separate Error Rate Calculation blocks calculate the error rates of the demodulated data. The block labeled SER Calculation compares the integer data to compute the symbol error rate statistics and the block labeled BER Calculation compares the bits data to compute the bit error rate statistics. The output of the Error Rate Calculation block is a threeelement vector containing the calculated error rate, the number of errors observed, and the amount of data processed.
To reduce simulation run time and ensure that the statistics of the errors remain stable as the Eb/N0 ratio increases, the model is configured to run until 100 errors occur or until 1e8 bits have been transmitted.
The model initializes variables used to configure block parameters by using the PreLoadFcn
callback function. For more information, see Model Callbacks (Simulink).
Produce Error Rate Curves
Compute the theoretical BER for nondifferential 8PSK in AWGN over a range of Eb/N0 values by using the
function. Simulate the berawgn
doc_gray_code
model with Graycoded symbol mapping over the same range of Eb/N0 values.
Compare Gray coding with binary coding, by modifying the MPSK Modulator Baseband and MPSK Demodulator Baseband blocks to set the Constellation ordering parameter to Binary
instead of Gray
. Simulate the doc_gray_code
model with binarycoded symbol mapping over the same range of Eb/N0 values.
Plot the results by using the semilogy
function. The Graycoded system achieves better error rate performance than the binarycoded system. Further, the Graycoded error rate aligns with the theoretical error rate statistics.
Ports
Input
In — Input data signal
vector  matrix
Input data signal, specified as an
N_{S}by1 vector or an
N_{S}byN_{C}
matrix. N_{S} represents the number of samples
in the input signal. N_{C} represents the
number of channels, as determined by the number of columns in the input signal matrix.
Both N_{S} and
N_{C} can be equal to 1
.
The block adds frames of lengthN_{S} Gaussian noise to each of the N_{C} channels, using a distinct random distribution per channel.
Data Types: double
 single
Complex Number Support: Yes
Var — Variance of additive white Gaussian noise
positive scalar  vector
Variance of additive white Gaussian noise, specified as a positive scalar or a 1byN_{C} vector. N_{C} represents the number of channels, as determined by the number of columns in the input signal matrix. For more information, see Specifying the Variance Directly or Indirectly.
Dependencies
To enable this port, set Mode to
Variance
and Noise variance
source to Input port
.
Data Types: double
Output
Out — Output data signal
vector  matrix
Output data signal for the AWGN channel, returned as a vector or matrix. The datatype and dimensions of Out match those of the input signal, In.
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink^{®} Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Mode — Variance mode
Signal to noise ratio (SNR)
(default)  Signal to noise ratio (Eb/No)
 Signal to noise ratio (Es/No)
 Variance
Variance mode, specified as Signal to noise ratio
(Eb/No)
, Signal to noise ratio (Es/No)
,
Signal to noise ratio (SNR)
, or
Variance
. For more information, see Relationship Among Eb/No, Es/No, and SNR Modes and
Specifying the Variance Directly or Indirectly.
SNR (dB) — Ratio of signal power to noise power
10
(default)  scalar  vector
Ratio of signal power to noise power in decibels, specified as a scalar or vector.
Tunable: Yes
Dependencies
To enable this parameter, set Mode to
Signal to noise ratio (SNR)
.
Eb/No (dB) — Ratio of information bit energy per symbol to noise power spectral density
10
(default)  scalar  vector
Ratio of information bit energy per symbol to noise power spectral density in decibels, specified as a scalar or vector. The information bit energy is the magnitude without channel coding.
Tunable: Yes
Dependencies
To enable this parameter, set Mode to
Signal to noise ratio (Eb/No)
.
Es/No (dB) — Ratio of information symbol energy per symbol to noise power spectral density
10
(default)  scalar  vector
Ratio of information symbol energy per symbol to noise power spectral density in decibels, specified as a scalar or vector. The information symbol energy is the magnitude without channel coding.
Tunable: Yes
Dependencies
To enable this parameter, set Mode to
Signal to noise ratio (Es/No)
.
Number of bits per symbol — Number of bits in each input symbol
1 (default)  scalar  vector
Number of bits in each input symbol, specified as a scalar or vector.
Dependencies
To enable this parameter, set Mode to
Signal to noise ratio (Eb/No)
.
Input signal power, referenced to 1 ohm (watts) — Mean square power of input
1
(default)  scalar  vector
Mean square power of the input in watts, specified as a scalar or vector.
Tunable: Yes
Dependencies
To enable this parameter, set Mode to
Signal to noise ratio (Eb/No)
, Signal to
noise ratio (Es/No)
, or Signal to noise ratio
(SNR)
.
Samples per symbol — Samples per symbol
1
(default)  positive scalar  vector
Samples per symbol in samples, specified as a positive scalar or vector.
Dependencies
To enable this parameter, set Mode to
Signal to noise ratio (Eb/No)
or Signal to
noise ratio (Es/No)
.
Noise variance source — Noise variance source
Parameter
(default)  Input port
Noise variance source, specified as a Parameter
or
Input port
. For more information, see Specifying the Variance Directly or Indirectly.
Tunable: Yes
Dependencies
To enable this parameter, set Mode to
Variance
.
Noise variance — Variance of white Gaussian noise
1
(default)  scalar  vector
Variance of the white Gaussian noise, specified as a scalar or vector. For more information, see Specifying the Variance Directly or Indirectly.
Tunable: Yes
Dependencies
To enable this port, set Mode to
Variance
and Noise variance
source to Parameter
.
Random number source — Random number source
Global stream
(default)  mt19937ar with seed
Random number source, specified as a Global stream
or
mt19937ar with seed
.
Tunable: Yes
Initial seed — Noise generator initial seed
67
(default)  positive scalar  vector
Noise generator initial seed for the mt19937ar algorithm, specified as a positive scalar or a 1byN_{C} vector.
When the input signal is complex, the block creates random data as:
randData
=randn
(2*N_{S},N_{C})noise
=randData
(1:2:end) + 1i(randData
(2:2:end))
You can specify different seed values for each DLL build.
Tunable: Yes
Dependencies
To enable this parameter, set Random number
source to mt19937ar with seed
.
Simulate using — Type of simulation to run
Code generation
(default)  Interpreted execution
Type of simulation to run, specified as Code generation
or
Interpreted execution
.
Code generation
— Simulate the model by using generated C code. The first time you run a simulation, Simulink generates C code for the block. The model reuses the C code for subsequent simulations unless the model changes. This option requires additional startup time, but the speed of the subsequent simulations is faster than with theInterpreted execution
option.Interpreted execution
— Simulate the model by using the MATLAB^{®} interpreter. This option shortens startup time, but the speed of subsequent simulations is slower than with theCode generation
option. In this mode, you can debug the source code of the block.
For more information, see Simulation Modes (Simulink).
Block Characteristics
Data Types 

Multidimensional Signals 

VariableSize Signals 

Tips
You can tune parameters in normal mode, accelerator mode, or rapid accelerator mode.
Unless otherwise indicated, parameters are nontunable.
For nontunable parameters, when you use the Simulink Coder™ rapid simulation (RSIM) target to build an RSIM executable, you cannot change their values without recompiling the model.
If a parameter is tunable, you can change its value at any time. This is useful for Monte Carlo simulations in which you run the simulation multiple times (such as on multiple computers) with different amounts of noise.
Algorithms
Relationship Among Eb/No, Es/No, and SNR Modes
For uncoded complex input signals, the AWGN Channel block relates E_{b}/N_{0, }E_{s}/N_{0}, and SNR according to these equations:
E_{s}/N_{0} = (T_{sym}/T_{samp}) × SNR
E_{s}/N_{0} = E_{b}/N_{0} + 10log_{10}(k) in dB
E_{s} represents the signal energy in joules.
E_{b} represents the bit energy in joules.
N_{0} represents the noise power spectral density in watts/Hz.
T_{sym}/T_{samp} equals the value of the Samples per symbol parameter.
T_{sym} is the symbol period of the signal, in seconds.
T_{samp} represents the inherited sample time of the block, in seconds.
k represents the number of information bits per input symbol, Number of bits per symbol.
For real signal inputs, the AWGN Channel block relates E_{s}/N_{0 }and SNR according to this equation:
E_{s}/N_{0} = 0.5 (T_{sym}/T_{samp}) × SNR
Note
All values of power assume a nominal impedance of 1 ohm.
The equation for the real case differs from the corresponding equation for the complex case by a factor of 2. Specifically, the object uses a noise power spectral density of N_{0}/2 watts/Hz for real input signals, versus N_{0} watts/Hz for complex signals.
For more information, see AWGN Channel Noise Level.
Specifying the Variance Directly or Indirectly
To directly specify the variance of the noise generated by AWGN Channel, specify the
Mode as
Variance
. When you set Noise variance
source to:
Parameter
— Specify the variance as a positive scalar or vector by using the Noise variance parameter.Input port
— Specify the variance as a positive scalar or vector by using the Var block input. The variance input sampling rate must equal that of the input signal.
When you specify variance as a:
Scalar, all signal channels are uncorrelated but share the same variance.
Vector whose length is the number of channels in the input signal, each element represents the variance of the corresponding signal channel.
Note
If you apply complex input signals to the AWGN Channel block, then it adds complex zeromean Gaussian noise with the calculated or specified variance. The variance for each quadrature component of the complex noise is half of the calculated or specified value.
To specify the variance indirectly, that is, to have the block calculate the variance, specify the Mode as:
Signal to noise ratio (Eb/No)
, where the block calculates the variance from these quantities that you specify in the dialog box:Eb/No (dB), the ratio of bit energy to noise power spectral density
Input signal power, referenced to 1 ohm (watts), the actual power of the symbols at the input of the block
Signal to noise ratio (Es/No)
, where the block calculates the variance from these quantities that you specify in the dialog box:Es/No (dB), the ratio of signal energy to noise power spectral density
Input signal power, referenced to 1 ohm (watts), the actual power of the symbols at the input of the block
Signal to noise ratio (SNR)
, where the block calculates the variance from these quantities that you specify in the dialog box:SNR (dB), the ratio of signal power to noise power
Input signal power, referenced to 1 ohm (watts), the actual power of the samples at the input of the block
Changing the symbol period in the AWGN Channel block affects the variance of the noise added per sample, which also causes a change in the final error rate.
$$NoiseVariance=\frac{SignalPower\times SymbolPeriod}{SampleTime\times {10}^{\frac{Es/No}{10}}}$$
Tip
Select the symbol period equal to the symbol period of the model. The value depends on what constitutes a symbol and what the oversampling applied to it is. For example, a symbol could have 3 bits and be oversampled by 4. For more information, see AWGN Channel Noise Level.
References
[1] Proakis, John G. Digital Communications. 4th Ed. McGrawHill, 2001.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced before R2006aR2023b: Variance calculation update
In R2023b, use Upgrade Advisor (Simulink) to update instances of the AWGN Channel block in your preR2023a models. In addition to the updates for R2023a, these AWGN Channel block updates occur for this configuration:
If the Mode parameter setting is
Signal to noise ratio (Eb/No)
orSignal to noise ratio (Es/No)
and Symbol period (s) together with the block sample time results in a noninteger samples per symbol, Mode gets set toSignal to noise ratio (SNR)
in the upgraded block.The SNR (db) parameter gets set to the appropriate SNR setting.
In R2023a, if the combination of the Symbol period (s) parameter value and the block sample time resulted in a noninteger samples per symbol, using Upgrade Advisor (Simulink) to update the AWGN Channel block generates noise with incorrect variance values.
If you have already updated your block in R2023a:
Select the AWGN Channel block in your model.
Run
set_param(gcb,'LegacyMode','on')
at the command line to revert the update.Rerun Upgrade Advisor.
R2023a: Variablesize support
This support enables you to vary the length of input signal each time the block executes in your simulation.
R2023a: Random number generator update
The AWGN Channel block updates the random number generator (RNG) source
permitting selection of Global stream
or mt19937ar with
seed
.
The new RNG provides better random number statistics. For simulations created before R2023a, the block defaults to legacy mode with prior RNG ( Ziggurat method  V5 RANDN algorithm). In this mode, the block uses the Random Source block to generate noise. Random numbers are generated using the Ziggurat method (V5 RANDN algorithm). The block reuses the same initial seeds every time you rerun the simulation, so that this block outputs the same signal each time you run a simulation. To improve statistics, it is recommended that you run Update Model on preR2023a simulations that use the AWGN Channel block.
R2023a: Code Generation
Code generation is enabled by default. For more information, see Simulate using.
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令：
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
 América Latina (Español)
 Canada (English)
 United States (English)
Europe
 Belgium (English)
 Denmark (English)
 Deutschland (Deutsch)
 España (Español)
 Finland (English)
 France (Français)
 Ireland (English)
 Italia (Italiano)
 Luxembourg (English)
 Netherlands (English)
 Norway (English)
 Österreich (Deutsch)
 Portugal (English)
 Sweden (English)
 Switzerland
 United Kingdom (English)