Search code examples
matlabsignalssignal-processingnoise

How can I calculate the SNR of a signal from its frequency spectrum?


I am pulling data from a spectrum analyzer and am trying to use the snr function from the signal processing toolbox to calculate the signal-to-noise ratio of the signal. The problem is that the value I am getting for the SNR makes no sense. I am calling the function like this:

snr(power, freqValues, rwb, 'power')

And the value of the snr I get is -28.0343 +13.6438i with rwb = 1.8e4; The graph created by snr looks like this: SNR And for reference this is what the frequency spectrum I am capturing looks like: (This is created from plot(freqValues, power)) freq The frequency ranges from 0-2MHz and the major peak is at 902kHz @10.4dBm. Any help is appreciated thanks.


Solution

  • When I read the MATLAB documentation for snr(), I see the following. Your input power as sxx is formatted incorrectly.

    sxx — Power spectrum

    nonnegative real-valued row or column vector

    Power spectrum, specified as a real-valued nonnegative row or column vector.

    The power spectrum must be expressed in linear units, not decibels. Use db2pow to convert decibel values to power values.