Matlab Add Awgn
MathWorksOfficialCreated by MathWorks
- Skill
- Tool integration
- Science and research
- BSD-2-Clause
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides the correct patterns for adding Additive White Gaussian Noise (AWGN) to signals and performing SNR conversions within MATLAB. It addresses common pitfalls in communications system modeling, specifically correcting the misuse of the 'measured' option in the awgn function and manual SNR formula errors. By enforcing explicit power calculations and standardized conversion functions, it ensures simulation results remain consistent with theoretical expectations.
What it does
- Provides correct calling conventions for the awgn function.
- Standardizes conversions between SNR, Eb/No, Es/No, and per-subcarrier SNR.
- Explains how to handle noise variance for soft-decision demodulation.
- Details specific adjustments for OFDM systems and fading channels.
- Identifies critical anti-patterns to avoid in simulation code.
- Offers guidance on validating simulation results against theoretical BER.
When to use it
- When adding noise to signals in link-level communications simulations.
- When converting between different SNR definitions like Eb/No or Es/No.
- When setting up coded, oversampled, or OFDM-based systems.
- When you need to pass noise variance to a soft-decision demodulator.
Advantages
- Prevents common simulation errors caused by incorrect power assumptions.
- Ensures consistency across different modulation and coding schemes.
- Provides validated, robust methods for SNR conversions.
- Improves the accuracy of soft-decision decoding by providing correct noise variance.
Usage examples
- “How do I add AWGN to a unit-power signal at 15 dB SNR?”
- Use the command [rxSig, noiseVar] = awgn(txSig, 15, 0); where 0 represents the signal power in dBW for a unit-power signal.
- “How do I convert 10 dB Eb/No to SNR for a 64-QAM system with 3/4 code rate?”
- Use the function snrDb = convertSNR(10, 'ebno', 'snr', BitsPerSymbol=6, CodingRate=0.75); to obtain the correct SNR value.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/matlab/matlab-add-awgn/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip matlab-add-awgn.zip -d .agents/skills
Documentation by MathWorks
AWGN & SNR Management
Add white Gaussian noise to signals and convert between SNR definitions (SNR, Eb/No, Es/No, per-subcarrier SNR) for communications system simulations.
When to Use
Adding noise to a signal in a link simulation
Converting between Eb/No, Es/No, SNR, or per-subcarrier SNR
Setting up the correct SNR for a coded, oversampled, or OFDM system
Obtaining noise variance to pass to a soft-decision demodulator
When NOT to Use
Configuring fading channels (delay profile, Doppler, antenna arrays)
Must-Follow Rules
NEVER pass
'measured'toawgn— Always pass explicit signal power as the third argument. For unit-power signals use0; otherwise compute power withmean(abs(x).^2)and convert to dBW:10*log10(sigPow). The'measured'option computes instantaneous power internally, which gives incorrect noise levels after fading channels and obscures the power assumption. Even in AWGN-only scenarios, explicit power is required for correctness and clarity. For OFDM systems, see the "Add AWGN in an OFDM link simulation" pattern.Use
UnitAveragePower=truewhen signal power doesn't matter — This is the simplest path: signal power = 0 dBW, soawgn(x, snr, 0)is exact. If the user needs original constellation scaling (e.g., PA modeling, hardware-in-the-loop), do NOT useUnitAveragePower=true— use the default modulator, compute the actual average power withmean(abs(x).^2), and pass it explicitly:awgn(x, snr, sigPowdBW).Use
convertSNRfor all conversions — NEVER compute SNR/Eb/No/Es/No formulas manually — Even when the formula is simple, always useconvertSNR. Manual formulas are error-prone for edge cases (oversampling, subcarrier loading) and bypass the toolbox's validated implementation. Anti-pattern:snr = ebno + 10*log10(bitsPerSymbol * codeRate). Correct:convertSNR(ebno, "ebno", "snr", BitsPerSymbol=6, CodingRate=3/4).Distinguish wideband SNR and per-subcarrier SNR in OFDM systems — Eb/No is a per-subcarrier quantity. To go from Eb/No to the wideband SNR that
awgnneeds, use two steps: (1)convertSNR(ebno, "ebno", "snr", BitsPerSymbol=..., CodingRate=...)gives the SNR per subcarrier, (2)convertSNR(snrsc, "snrsc", "snr", FFTLength=..., NumActiveSubcarriers=...)gives the wideband SNR forawgn. Directebno→snrscis not supported and throws an error. Caveat: If the user asks for per-subcarrier SNR only, step 1 alone is the complete answer — do NOT apply step 2. Applying the FFTLength/NumActiveSubcarriers correction to a per-subcarrier value gives the wideband SNR, which is a different (lower) quantity. Note: The"snrsc"mode requires R2023b or later. For R2022a–R2023a, compute wideband SNR manually:snr_wideband = snr_per_sc - 10*log10(FFTLength/NumActiveSubcarriers). To add noise at a per-subcarrier SNR, see the "Add AWGN in an OFDM link simulation" pattern below.Capture noise variance for soft demodulation — Use
[y, nVar] = awgn(...)and passnVarto the demodulator viaNoiseVariance=nVar.Do NOT reference skill rules or prohibitions in generated code comments — Write positive, descriptive comments that explain intent, using a style similar to the example code provided in this skill. The end user does not know about this skill.
Critical Anti-Patterns — NEVER Do These
NEVER use 'measured' with awgn
% WRONG — never generate this
rxSignal = awgn(txSignal, snrdB, 'measured');
% CORRECT for unit-power signals (UnitAveragePower=true)
rxSignal = awgn(txSignal, snrdB, 0);
% CORRECT for non-unit-power signals
sigPow = mean(abs(txSignal).^2);
rxSignal = awgn(txSignal, snrdB, 10*log10(sigPow));NEVER compute SNR conversions manually
% WRONG — never generate manual formulas like these
SNR_dB = EbNo_dB + 10*log10(k * codeRate);
SNR_dB = EbNo_dB + 10*log10(k * codeRate) - 10*log10(oversamplingFactor);
EsNo = EbNo + 10*log10(bitsPerSymbol);
% CORRECT — always use convertSNR
snrDb = convertSNR(ebnoDb, "ebno", "snr", BitsPerSymbol=6, CodingRate=3/4);
snrDb = convertSNR(ebnoDb, "ebno", "snr", BitsPerSymbol=6, CodingRate=3/4, SamplesPerSymbol=4);
esnoDb = convertSNR(ebnoDb, "ebno", "esno", BitsPerSymbol=6);Key Functions
| Function | Purpose |
|---|---|
awgn | Add AWGN to a signal at a specified SNR |
convertSNR | Convert between ebno, esno, snr, and snrsc |
berawgn | Theoretical BER over AWGN for standard modulations (PSK, QAM, FSK, DPSK, PAM) |
Gotchas
Why 'measured' is banned (background)
Thermal noise in a receiver is dominated by the noise figure and bandwidth — it does not change when the signal fades. The 'measured' option in awgn computes instantaneous signal power and scales noise to match, which artificially keeps the instantaneous SNR constant through fades. It also hides the power assumption, making code harder to verify. Always pass explicit power instead.
% WRONG after fading: Noise tracks fading — instantaneous SNR stays constant
rxFaded = fadingChannel(txSig);
rxNoisy = awgn(rxFaded, snr, 'measured');
% CORRECT: Compute signal power before fading, pass explicitly
sigPow = mean(abs(txSig).^2);
sigPowdBW = 10*log10(sigPow);
rxFaded = fadingChannel(txSig);
rxNoisy = awgn(rxFaded, snr, sigPowdBW);
% SIMPLEST: Use unit-power signal, then 0 dBW is exact
txSig = qammod(data, M, UnitAveragePower=true); % power = 0 dBW
rxFaded = fadingChannel(txSig);
rxNoisy = awgn(rxFaded, snr, 0);awgn default assumes 0 dBW signal power
Calling awgn(x, snr) without a third argument assumes the signal has 0 dBW (1W) average power. This is only correct if the signal actually has unit average power. For non-normalized signals, compute the actual power and pass it explicitly.
ebno↔snrsc conversion is not supported
convertSNR supports these paths:
| From | To | Supported | Notes |
|---|---|---|---|
ebno | snr | Yes | For OFDM: gives SNR per subcarrier (not wideband) |
ebno | esno | Yes | |
esno | snr | Yes | |
snr | snrsc | Yes | "snr" = wideband SNR, "snrsc" = per-subcarrier |
ebno | snrsc | No | Throws error. Use two-step: ebno→"snr" then "snrsc"→"snr" |
esno | snrsc | No | Throws error. Same two-step path required |
snrsc | ebno | No | Use two-step: "snrsc"→"snr" then "snr"→"ebno" |
snrsc | esno | No | Use two-step: "snrsc"→"snr" then "snr"→"esno" |
Fading channel path gain normalization
The awgn(rxFaded, snr, 0) pattern assumes the fading channel preserves
average signal power. This is true when NormalizePathGains=true (the default
for comm.RayleighChannel and comm.RicianChannel). If NormalizePathGains
is false, the channel applies its actual path gains and the average received
power shifts — you must account for this in the power argument to awgn.
% NormalizePathGains=true (default): pre-fading power is correct
chan = comm.RayleighChannel(NormalizePathGains=true, ...);
rxFaded = chan(txSig);
rxNoisy = awgn(rxFaded, snr, 0); % 0 dBW is still correct
% NormalizePathGains=false: adjust for average path gain
chan = comm.RayleighChannel(NormalizePathGains=false, ...
AveragePathGains=[0 -3 -6], ...);
avgGaindB = 10*log10(sum(10.^(chan.AveragePathGains/10)));
rxFaded = chan(txSig);
rxNoisy = awgn(rxFaded, snr, avgGaindB); % account for channel gainChannel output normalization in OFDM (5G / WLAN)
5G channels (nrTDLChannel, nrCDLChannel), WLAN channels (wlanTGnChannel, wlanTGacChannel, etc.), and the Communications Toolbox comm.MIMOChannel and comm.RayTracingChannel have a NormalizeChannelOutputs property (default: true) that divides the channel output power by the number of receive antennas. Other Communications Toolbox channels (comm.RayleighChannel, comm.RicianChannel) do not have this property.
When NormalizeChannelOutputs=true, the analytical OFDM signal power must account for the nRxAnts scaling:
% Base OFDM signal power
sigPow = 10*log10(numAvailableSC / nfft^2);
% Adjust for NormalizeChannelOutputs=true (5G/WLAN channels)
sigPow = sigPow - 10*log10(nRxAnts);
% Additionally adjust for NormalizePathGains=false (if applicable)
sigPow = sigPow + avgGaindB;Both properties default to true for 5G/WLAN channels, so the common case only requires the nRxAnts correction. If NormalizePathGains is also set to false, apply both adjustments.
If NormalizeChannelOutputs=false, no nRxAnts correction is needed — use the base formula.
Noise variance is total, not per-component
The second output of awgn is the total noise variance. For complex signals, the per-component (I or Q) variance is half this value:
[y, nVar] = awgn(x, snr, 0);
% nVar = total noise variance
% nVar/2 = per-component (I or Q) varianceberawgn takes Eb/No, not SNR
If you have SNR, convert to Eb/No first:
ebno = convertSNR(snr, "snr", "ebno", BitsPerSymbol=log2(M));
ber = berawgn(ebno, 'qam', M);Patterns
Add AWGN to a unit-power signal
M = 16;
data = randi([0 M-1], 1000, 1);
txSig = qammod(data, M, UnitAveragePower=true);
snrdB = 15;
[rxSig, noiseVar] = awgn(txSig, snrdB, 0);Convert Eb/No to SNR for a coded system
M = 64; % 64-QAM
bitsPerSymbol = log2(M); % 6
codeRate = 3/4; % LDPC code rate
samplesPerSymbol = 4; % Pulse shaping oversampling
ebnoDb = 10;
snrDb = convertSNR(ebnoDb, "ebno", "snr", ...
BitsPerSymbol=bitsPerSymbol, ...
CodingRate=codeRate, ...
SamplesPerSymbol=samplesPerSymbol);OFDM conversion: Eb/No → per-subcarrier SNR → wideband SNR
In the OFDM context, convertSNR(ebno, "ebno", "snr") returns the SNR per subcarrier (not wideband SNR). To get the wideband SNR needed by awgn, convert from "snrsc" to "snr".
M = 64;
bitsPerSymbol = log2(M);
codeRate = 3/4;
fftLen = 256;
numActiveSC = 200;
ebnoDb = 10;
% Step 1: Eb/No → per-subcarrier SNR
snrscDb = convertSNR(ebnoDb, "ebno", "snr", ...
BitsPerSymbol=bitsPerSymbol, ...
CodingRate=codeRate);
% Step 2: Per-subcarrier SNR → wideband SNR (for awgn)
snrWbDb = convertSNR(snrscDb, "snrsc", "snr", ...
FFTLength=fftLen, ...
NumActiveSubcarriers=numActiveSC);Add AWGN in an OFDM link simulation (per-subcarrier SNR)
In OFDM link simulations, SNR is defined per subcarrier. Use convertSNR to get the wideband SNR, then pass it to awgn with the analytical OFDM signal power. Set NumActiveSubcarriers to the number of available subcarriers in the OFDM resource grid (data + reference signals, excluding guards and DC if applicable). In 5G/LTE this equals carrier.NSizeGrid*12 — the resource grid does not include guard bands. In WLAN, it is the number of data + pilot subcarriers. Do NOT compute signal power from mean(abs(txWaveform).^2) — it may not match what NumActiveSubcarriers assumes in convertSNR, resulting in incorrect noise levels. Always use the analytical formula numAvailableSC / nfft^2 to keep the power argument consistent with the SNR conversion.
% Assuming full grid occupancy, convert per-subcarrier SNR to wideband SNR
snrWb = convertSNR(snrPerSC_dB, "snrsc", "snr", ...
FFTLength=nfft, NumActiveSubcarriers=numAvailableSC);
% Maximum signal power assuming full grid, consistent with convertSNR
sigPow = 10*log10(numAvailableSC / nfft^2);
% Add noise at the calculated wideband SNR and signal power
rxNoisy = awgn(rxWaveform, snrWb, sigPow);numAvailableSC is the number of subcarriers excluding guard bands and any DC null — i.e., the subcarriers available for data, reference signals, and control. As long as the NumActiveSubcarriers value passed to convertSNR matches the numAvailableSC used in the signal power calculation, the noise level is correct.
Do NOT compute received waveform power — that gives wideband SNR, not per-subcarrier SNR.
For 5G workflows (nrTDLChannel/nrCDLChannel, nrOFDMModulate), add noise using the N0/randn form as in the shipped 5G examples — see references/5g-link-noise.md, which covers the form, the awgn equivalent, the frequency-domain noise variance for the receiver (nrEqualizeMMSE, nrPDSCHDecode), the NormalizeChannelOutputs=false case, and non-unit-power scaling.
Capture noise variance for soft-decision demodulation
M = 16;
data = randi([0 M-1], 1000, 1);
txSig = qammod(data, M, UnitAveragePower=true);
snrDb = 12;
[rxSig, noiseVar] = awgn(txSig, snrDb, 0);
% Pass noise variance to demodulator for accurate LLR computation
softBits = qamdemod(rxSig, M, UnitAveragePower=true, ...
OutputType="llr", ...
NoiseVariance=noiseVar);OFDM note: When noise is added to the time-domain waveform (after ofdmmod) and demodulation is performed in the frequency domain (after ofdmdemod), the FFT scales the noise variance by nfft. Pass noiseVar * nfft to the demodulator's NoiseVariance parameter — not the time-domain noiseVar returned by awgn.
After Adding Noise
Validate against theory — Compare simulated BER to theoretical BER using
berawgn. See references/snr-conversion-guide.md.Estimate required Eb/No — If the user asks for the Eb/No or SNR needed to achieve a target BER/BLER/FER, refer to the "Estimate required Eb/No" section in references/snr-conversion-guide.md.
Visualize the noisy signal — Use
scatterplotorcomm.ConstellationDiagramto inspect the received constellation.Measure EVM — Use
comm.EVMto quantify signal degradation from noise.
References
| Load when... | Reference |
|---|---|
Need theoretical BER curves, conversion formulas, berawgn usage, or common system examples | references/snr-conversion-guide.md |
Adding noise to a 5G waveform, or need the noise variance for the 5G receiver (nrEqualizeMMSE, nrPDSCHDecode) | references/5g-link-noise.md |
Copyright 2026 The MathWorks, Inc.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.4 KiB
- SKILL.md14.6 KiB
- manifest.yaml501 B
- references/5g-link-noise.md2.3 KiB
- references/snr-conversion-guide.md8.4 KiB
references/snr-conversion-guide.md
SNR Conversion Guide & Theoretical BER
Manual Fallback: SNR ↔ Per-Subcarrier SNR (pre-R2023b)
The "snrsc" mode in convertSNR requires R2023b or later. For R2022a–R2023a, use this formula:
SNR_sc = SNR + 10*log10(FFTLength / NumActiveSubcarriers)FFTLength= total number of subcarriers (including guards and DC)NumActiveSubcarriers= number of data + pilot subcarriersSNR_sc > SNR because energy is concentrated on fewer subcarriers
All other conversions (Eb/No↔Es/No, Eb/No↔SNR, Es/No↔SNR) are handled by convertSNR (available since R2022a). Always use convertSNR — never compute these manually. For details, refer to the convertSNR documentation.
Valid convertSNR Conversions
| From → To | Supported | Required Name-Value Parameters |
|---|---|---|
ebno → esno | Yes | BitsPerSymbol |
esno → ebno | Yes | BitsPerSymbol |
ebno → snr | Yes | BitsPerSymbol, CodingRate, SamplesPerSymbol |
snr → ebno | Yes | BitsPerSymbol, CodingRate, SamplesPerSymbol |
esno → snr | Yes | CodingRate, SamplesPerSymbol |
snr → esno | Yes | CodingRate, SamplesPerSymbol |
snr → snrsc | Yes | FFTLength, NumActiveSubcarriers |
snrsc → snr | Yes | FFTLength, NumActiveSubcarriers |
ebno → snrsc | No | Throws error. Use two-step: ebno→"snr" then "snrsc"→"snr" |
esno → snrsc | No | Throws error. Same two-step path required |
snrsc → ebno | No | Use two-step: "snrsc"→"snr" then "snr"→"ebno" |
snrsc → esno | No | Use two-step: "snrsc"→"snr" then "snr"→"esno" |
Key insight for OFDM:
convertSNR(ebno, "ebno", "snr")returns the SNR per subcarrier (not wideband SNR). Do NOT pass this directly toawgn(). You must convert viaconvertSNR(snrsc, "snrsc", "snr", ...)to get wideband SNR, which subtracts10*log10(nFFT/nActiveSC). Skipping this step overestimates SNR — for example, ~0.90 dB too much for 64-FFT with 52 active subcarriers, producing ~0.36x theoretical BER.
convertSNR Name-Value Parameters
| Parameter | Default | When It Matters |
|---|---|---|
BitsPerSymbol | 1 | Any conversion involving ebno or esno |
CodingRate | 1 | Any conversion involving snr when FEC is used |
SamplesPerSymbol | 1 | Any conversion involving snr when oversampling (pulse shaping) |
FFTLength | 64 | Any conversion involving snrsc |
NumActiveSubcarriers | 64 | Any conversion involving snrsc |
Theoretical BER with berawgn
berawgn computes exact theoretical BER for standard modulations over AWGN. The input is always Eb/No in dB.
Supported Modulations
% PSK (phase shift keying)
ber = berawgn(ebno, 'psk', M, 'nondiff'); % M = 2, 4, 8, 16, ...
ber = berawgn(ebno, 'psk', M, 'diff'); % Differentially encoded
% QAM (quadrature amplitude modulation)
ber = berawgn(ebno, 'qam', M); % M = 4, 8, 16, 32, 64, ...
% FSK (frequency shift keying)
ber = berawgn(ebno, 'fsk', M, 'coherent');
ber = berawgn(ebno, 'fsk', M, 'noncoherent');
% DPSK (differential phase shift keying)
ber = berawgn(ebno, 'dpsk', M);
% PAM (pulse amplitude modulation)
ber = berawgn(ebno, 'pam', M);Example: Plot Theoretical BER Curves
ebnoVec = 0:0.5:20;
berBPSK = berawgn(ebnoVec, 'psk', 2, 'nondiff');
berQPSK = berawgn(ebnoVec, 'psk', 4, 'nondiff');
berQAM16 = berawgn(ebnoVec, 'qam', 16);
berQAM64 = berawgn(ebnoVec, 'qam', 64);
berQAM256 = berawgn(ebnoVec, 'qam', 256);
semilogy(ebnoVec, berBPSK, ebnoVec, berQPSK, ebnoVec, berQAM16, ...
ebnoVec, berQAM64, ebnoVec, berQAM256);
grid on;
xlabel('Eb/No (dB)');
ylabel('BER');
legend('BPSK', 'QPSK', '16-QAM', '64-QAM', '256-QAM');
title('Theoretical BER over AWGN');Example: Compare Simulated vs Theoretical BER
M = 16;
bitsPerSymbol = log2(M);
ebnoVec = 0:2:16;
numBits = 1e6;
berSim = zeros(size(ebnoVec));
for idx = 1:length(ebnoVec)
snrDb = convertSNR(ebnoVec(idx), "ebno", "snr", ...
BitsPerSymbol=bitsPerSymbol);
txBits = randi([0 1], numBits, 1);
txSig = qammod(txBits, M, InputType="bit", UnitAveragePower=true);
rxSig = awgn(txSig, snrDb, 0);
rxBits = qamdemod(rxSig, M, OutputType="bit", UnitAveragePower=true);
[~, berSim(idx)] = biterr(txBits, rxBits);
end
berTheory = berawgn(ebnoVec, 'qam', M);
semilogy(ebnoVec, berTheory, '-', ebnoVec, berSim, 'o');
grid on;
xlabel('Eb/No (dB)');
ylabel('BER');
legend('Theoretical', 'Simulated');
title('16-QAM BER: Simulated vs Theoretical');Estimate Required Eb/No for a Target BER
Use berawgn over a fine Eb/No range and interpolate to estimate the crossing point. Works for any modulation berawgn supports (PSK, QAM, FSK, DPSK, PAM). The result is an estimate — accuracy depends on the Eb/No step size.
% Estimate Eb/No needed for 16-QAM BER = 1e-5
targetBER = 1e-5;
M = 16;
ebnoVec = 0:0.1:25;
berVec = berawgn(ebnoVec, 'qam', M);
reqEbNoDb = interp1(log10(berVec), ebnoVec, log10(targetBER));
% Result: ~13.4 dBThis approach generalizes to any standard modulation — just change the berawgn call:
% Estimate Eb/No for BPSK BER = 1e-6
berVec = berawgn(ebnoVec, 'psk', 2, 'nondiff');
reqEbNoDb = interp1(log10(berVec), ebnoVec, log10(1e-6));
% Result: ~10.5 dB
% Estimate Eb/No for 64-QAM BER = 1e-3
berVec = berawgn(ebnoVec, 'qam', 64);
reqEbNoDb = interp1(log10(berVec), ebnoVec, log10(1e-3));
% Result: ~14.8 dBNote:
interp1works onlog10(berVec)because BER curves are approximately linear on a log scale. Use a fine Eb/No step (0.1 dB) for sub-0.1 dB accuracy. Results are estimates, not exact analytical values.
Common System Configurations
QPSK, Rate-1/2, No Oversampling
ebnoDb = 5;
snrDb = convertSNR(ebnoDb, "ebno", "snr", ...
BitsPerSymbol=2, CodingRate=1/2);
% snrDb = 5 + 10*log10(2 * 0.5 / 1) = 5 + 0 = 5 dB64-QAM, Rate-3/4, 4x Oversampling
ebnoDb = 10;
snrDb = convertSNR(ebnoDb, "ebno", "snr", ...
BitsPerSymbol=6, CodingRate=3/4, SamplesPerSymbol=4);
% snrDb = 10 + 10*log10(6 * 0.75 / 4) = 10 + 0.51 = 10.51 dB256-QAM, Rate-5/6, OFDM (2048-FFT, 1200 Active)
Use the two-step conversion from Eb/No to wideband SNR:
ebnoDb = 20;
% Step 1: Eb/No → per-subcarrier SNR
snrscDb = convertSNR(ebnoDb, "ebno", "snr", ...
BitsPerSymbol=8, CodingRate=5/6);
% snrscDb = 20 + 10*log10(8 * 5/6) = 20 + 8.24 = 28.24 dB
% Step 2: Per-subcarrier SNR → wideband SNR (for awgn)
% Subtracts 10*log10(nFFT/nActiveSC)
snrWbDb = convertSNR(snrscDb, "snrsc", "snr", ...
FFTLength=2048, NumActiveSubcarriers=1200);
% snrWbDb = 28.24 - 10*log10(2048/1200) = 28.24 - 2.32 = 25.92 dBEstimate required Eb/No
Use this section when the user asks for the Eb/No or SNR needed to achieve a target BER, BLER, or FER.
Decision tree
Modulation supported by
berawgnorberfading?Yes → Use the analytical function with
fzeroorinterp1to find the Eb/No crossing point.No → Run Monte Carlo simulations sweeping Eb/No.
Channel type:
AWGN: Use
berawgn(ebnoRange, modType, M)directly.Flat or frequency-selective fading (single-carrier): Use
berfading(ebnoRange, modType, M, ...)if supported.OFDM: Assume flat fading per subcarrier. If the modulation is supported by
berawgnorberfading, use the analytical approach per subcarrier; otherwise, simulate.
Converting result to wideband SNR:
Convert per-subcarrier Eb/No to wideband SNR using the two-step process (see "256-QAM, Rate-5/6, OFDM" example above) to set the noise level for
awgn.
Example: Find Eb/No for target BER using fzero
% Find Eb/No for BER = 1e-5 with 16-QAM over AWGN
targetBER = 1e-5;
M = 16;
f = @(ebnoDb) berawgn(ebnoDb, 'qam', M) - targetBER;
requiredEbNo = fzero(f, [0 20]);
% requiredEbNo ≈ 13.4 dBExample: Find Eb/No for target BER using interp1
% Sweep Eb/No and interpolate
ebnoRange = 0:0.1:20;
ber = berawgn(ebnoRange, 'qam', 16);
targetBER = 1e-5;
requiredEbNo = interp1(ber, ebnoRange, targetBER);
% requiredEbNo ≈ 13.4 dB (accuracy depends on step size)When to simulate
If the scenario is not supported analytically (e.g., custom modulation, non-standard channel model, or coded systems where berfading doesn't apply), run Monte Carlo simulations sweeping Eb/No and use interp1 on the simulated BER curve.
Copyright 2026 The MathWorks, Inc.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- MathWorks
- Publisher
- MathWorks (Official)
- Source
- matlab/matlab-agentic-toolkit · skills-catalog/wireless-communications/matlab-add-awgn · commit 2a7f215
- Licence
- BSD 2-Clause License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by MathWorks or MathWorks.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download matlab-add-awgn.zip