2
votes

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 ?

1
i cannot reproduce your result. I can get ~25 with your code.lennon310
what is your input signal @lennon310Kasparov92

1 Answers

4
votes

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