calculating SNR for a Signal

14,561

You should take this into account:

  • awgn assumes the signal has unit power
  • the SNR argument of awgn is in dB
  • SNR is estimated as power of signal divided by power of noise, or approximately power of noised signal divided by power of noise.

See the following example:

signal = randn(1,1e6); %// example signal with approximately unit power
S = mean(signal.^2); %// actual signal power
noisedSignal = awgn(signal, 25);
SN = mean(noisedSignal.^2); %// power of noised signal
N = mean((signal-noisedSignal).^2);
SN/N
10^(25/10)

This gives

ans =
  316.9019
ans =
  316.2278

so the computed SNR (SN/N) is very similar to the expected value (10^(25/10)).

Share:
14,561
Kasparov92
Author by

Kasparov92

I am a Computer Science Researcher, currently teacher assistant in my university. I am doing my masters in Machine Learning. I enjoyed making other projects like a mini search engine, strategy game, image hiding and other projects we had in the faculty. I love chess very much and during faculty time I made a chess with AI using java.

Updated on June 04, 2022

Comments

  • Kasparov92
    Kasparov92 almost 2 years

    I am adding some white Gaussian noise on a signal in MATLAB 2008 R2

    noisedSignal = awgn(signal, 25);% 25 is the SNR
    

    but then when I calculate the SNR in the noisedSignal

    snr = GetSNR(noisedSignal, noisedSignal-signal);
    

    and

    function SNR = GetSNR(signal, errorSignal)
        SNR = 20 * log10(sqrt(mean(signal.^2))/sqrt(mean(errorSignal.^2)));
    end   
    

    the SNR calculated is 1.1818 which is not 25. What am I missing ?