convertSNR
Convert SNR values
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/No 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);
sig1 = qammod(d,M,InputType="bit");
qam = txfilter(sig1);
Convert the Eb/No value of 10 dB to an SNR value and add the noise equivalent to the filtered modulated signal.
EbNo = 10; SNR = convertSNR(EbNo,"ebno",BitsPerSymbol=k, ... SamplesPerSymbol=nSamp,CodingRate=1/3)
SNR = 5.2288
[sig2,var] = awgn(qam,SNR);
y = rxfilter(sig2);
outsignal = qamdemod(y,M,OutputType="llr",NoiseVariance=var);
Plot the demodulated QAM signal.
figure plot(outsignal,'.') 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/No)."esno"
—x
is the energy per symbol to noise power spectral density ratio (Es/No)."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/No)."esno"
—y
is the energy per symbol to noise power spectral density ratio (Es/No)."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 , snr to
ebno | bitspersymbol , codingrate ,
samplespersymbol |
ebno to esno , esno to
ebno | bitspersymbol , codingrate |
esno to snr , snr to
esno | samplespersymbol |
Version History
Introduced in R2022a
See Also
Apri esempio
Si dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi 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)