matlab/matlab-agentic-toolkit/matlab-add-awgn
Claude Code and agent skill by matlab/matlab-agentic-toolkit
- community
Checking that the SKILL.md file is still in the repository.
Read BEFORE writing any code that adds Additive White Gaussian Noise (AWGN) to signals and converts between SNR, Eb/No, Es/No, and per-subcarrier SNR for communications simulations, using awgn(), convertSNR(), berawgn(). The default MATLAB patterns for AWGN (e.g., 'measured' option, manual SNR formulas) produce subtly incorrect results. This skill specifies the correct calling conventions, required function usage, and critical anti-patterns that must be avoided.
Install
npx vskill@latest install matlab/matlab-agentic-toolkit/matlab-add-awgnSKILL.md
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'` to `awgn` — Always pass explicit signal power as the third argument. For unit-power signals use
0; 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=true` when signal power doesn't matter — This is the simplest path: signal power = 0 dBW, so
awgn(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 `convertSNR` for all conversions — NEVER compute SNR/Eb/No/Es/No formulas manually — Even when the formula is simple, always use
convertSNR. 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
NEVER compute SNR conversions manually
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.
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.
Channel 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:
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:
berawgn takes Eb/No, not SNR
If you have SNR, convert to Eb/No first:
Patterns
Add AWGN to a unit-power signal
Convert Eb/No to SNR for a coded system
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".
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.
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.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills-catalog/wireless-communications/matlab-add-awgn/SKILL.md
Popularity
- Repository stars
- 1,028
- Repository forks
- 128
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/matlab/matlab-agentic-toolkit/matlab-add-awgn)