Main Content

convertSNR

Convert SNR values

Since R2022a

    Description

    example

    y = convertSNR(x,inputmode) converts the input signal-to-noise ratio value x to an SNR.

    y = convertSNR(x,inputmode,outputmode) converts the input signal-to-noise ratio value x to outputmode.

    example

    y = convertSNR(x,inputmode,Name=Value) specifies additional name-value arguments.

    Examples

    collapse all

    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")

    Figure contains an axes object. The axes object contains 2 objects of type line. These objects represent Perfect Signal, Noisy Signal.

    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 Eb/N0 to the modulated signal. To do so, first convert the Eb/N0 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')

    Figure contains an axes object. The axes object with xlabel Bit Number, ylabel LLR contains a line object which displays its values using only markers.

    Input Arguments

    collapse all

    Input value, specified as a numeric row vector.

    Data Types: double

    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.

    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)

    Samples per symbol, specified as a positive integer. The function ignores SamplesPerSymbol value if you set:

    For more information, see Input mode to output mode conversion.

    Data Types: double

    Bits per symbol, specified as a positive integer. The function ignores BitsPerSymbol value if you set:

    For more information, see Input mode to output mode conversion.

    Data Types: double

    Coding rate, specified as a scalar in the range (0, 1]. The function ignores CodingRate value if you set:

    For more information, see Input mode to output mode conversion.

    Data Types: double

    Output Arguments

    collapse all

    Output value, returned as a row vector of numeric values.

    More About

    collapse all

    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 ConversionParameters 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