convertSNR
Syntax
Description
Examples
Add Noise to 8-PSK Modulated Signal for Eb/No Value
Generate random data symbols and the 8-PSK modulated signal.
d = randi([0 7],100,1); M = 8; % 8-PSK k = log2(M); % bits per symbol psk = pskmod(d,M);
Add the noise equivalent of a 6 dB Eb/No value to the modulated signal. To do so, first convert the Eb/No value to an SNR.
EbNo = 6;
SNR = convertSNR(EbNo,'ebno',BitsPerSymbol=k)
SNR = 10.7712
y = awgn(psk,SNR);
Plot the signal with and without the noise component.
figure plot(real(psk)); hold on plot(real(y)) legend("Perfect Signal","Noisy Signal")
Convert Eb/N0 Value to SNR Value
Set the simulation parameters
M = 16; % Modulation order k = log2(M); % bits per symbol nSamp = 4; % Number of samples
Create the raised cosine transmit and receive filters
txfilter = comm.RaisedCosineTransmitFilter( ... OutputSamplesPerSymbol=nSamp); rxfilter = comm.RaisedCosineReceiveFilter( ... InputSamplesPerSymbol=nSamp, ... DecimationFactor=nSamp);
Generate random data symbols and the filtered 16-QAM modulated signal.
d = randi([0 1],1000,1);
modsig = qammod(d,M,InputType="bit");
txsig = txfilter(modsig);
Add the noise equivalent of 10 dB to the modulated signal. To do so, first convert the value to SNR.
EbN0 = 10; snr = convertSNR(EbN0,"ebno", ... BitsPerSymbol=k, ... SamplesPerSymbol=nSamp, ... CodingRate=1/3)
snr = 5.2288
[sig2,var] = awgn(txsig,snr); rxsig = rxfilter(sig2); demodsig = qamdemod(rxsig,M, ... OutputType="llr", ... NoiseVariance=var);
Plot the demodulated QAM signal.
plot(demodsig,'.') xlabel('Bit Number') ylabel('LLR')
Input Arguments
x
— Input value
numeric row vector
Input value, specified as a numeric row vector.
Data Types: double
inputmode
— Input mode
"ebno"
| "esno"
| "snr"
Input mode, specified as "ebno"
, "esno"
, or
"snr"
.
"ebno"
—x
is the energy per bit to noise power spectral density ratio (Eb/N0)."esno"
—x
is the energy per symbol to noise power spectral density ratio (Es/N0)."snr"
—x
is the SNR.
outputmode
— Output mode
"ebno"
| "esno"
| "snr"
Output mode for y
, specified as "ebno"
,
"esno"
, or "snr"
.
"ebno"
—y
is the energy per bit to noise power spectral density ratio (Eb/N0)."esno"
—y
is the energy per symbol to noise power spectral density ratio (Es/N0)."snr"
—y
is the SNR.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: y =
convertSNR(x,inputmode,outputmode,SamplesPerSymbol=2)
SamplesPerSymbol
— Samples per symbol
1
(default) | positive integer
Samples per symbol, specified as a positive integer. The function ignores
SamplesPerSymbol
value if you set:
inputmode
to"ebno"
andoutputmode
to"esno"
.inputmode
to"esno"
andoutputmode
to"ebno"
.
For more information, see Input mode to output mode conversion.
Data Types: double
BitsPerSymbol
— Bits per symbol
1
(default) | positive integer
Bits per symbol, specified as a positive integer. The function ignores
BitsPerSymbol
value if you set:
inputmode
to"esno"
andoutputmode
to"snr"
.inputmode
to"snr"
andoutputmode
to"esno"
.
For more information, see Input mode to output mode conversion.
Data Types: double
CodingRate
— Coding rate
1
(default) | scalar in the range (0, 1]
Coding rate, specified as a scalar in the range (0, 1]. The function ignores
CodingRate
value if you set:
inputmode
to"esno"
andoutputmode
to"snr"
.inputmode
to"snr"
andoutputmode
to"esno"
.
For more information, see Input mode to output mode conversion.
Data Types: double
Output Arguments
y
— Output value
row vector of numeric values
Output value, returned as a row vector of numeric values.
More About
Input mode to output mode conversion
The following table shows the parameters used in conversion based on the choice of
inputmode
and
outputmode
. The
default value for all the parameters is 1
.
inputmode to outputmode
Conversion | Parameters used |
---|---|
"ebno" to "snr" | BitsPerSymbol , CodingRate , and SamplesPerSymbol |
"snr" to "ebno" | |
"ebno" to "esno" | CodingRate and BitsPerSymbol |
"esno" to "ebno" | |
"esno" to "snr" | SamplesPerSymbol |
"snr" to "esno" |
Version History
Introduced in R2022a
See Also
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)