Main Content

convertSNR

Convert SNR values

    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);
    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')

    Figure contains an axes object. The axes object contains an object of type line.

    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/No).

    • "esno"x is the energy per symbol to noise power spectral density ratio (Es/No).

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

    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, snr to ebnobitspersymbol, codingrate, samplespersymbol
    ebno to esno, esno to ebnobitspersymbol, codingrate
    esno to snr, snr to esnosamplespersymbol

    Version History

    Introduced in R2022a

    See Also