I'm studying a system's transient characteristics with awgn added to an input signal and I need to calculate $\text{SNR}$ before and after filtration.

Here is my code to generate input and output:

b=[0 K0];
a=[1 K0-1];
uinp=[1 ones(1,N-1)];
sn=0   ;               % SNR on input signal
levs=0  ;              
uout=filter(b, a, uinp);

The input signal has an $\text{SNR}$ equal to $1$ (or $0\, \text{dB}$).
How can I calculate the $\text{SNR}$ of the output signal?

I've tried to calculate the noise power (as without noise, the mean equals 1 after the transient, so I can just divide), but not sure if it is correct:

sum((uout-mean(uout)).^2)/length(uout) % = 1.5366
sum((uinp-mean(uinp)).^2)/length(uinp) %= 1.0236

1 Answer 1


What about the MATLAB SNR Function?

  • $\begingroup$ I've tried it, assuming that f(signal+noise)=f(signal)+f(noise) where f is a filter function. Looks true enough, but I'm not sure $\endgroup$
    – lazba
    Oct 25, 2022 at 4:07
  • $\begingroup$ There's a lot to unpack here. My advice is to run the examples that MATLAB provides for awgn() and snr(). $\endgroup$
    – user58975
    Oct 25, 2022 at 4:41
  • 1
    $\begingroup$ I've did it using snr(signal,noise), where signal is if filter signal without noise, and noise is filter noisedSignal-clearSignal $\endgroup$
    – lazba
    Oct 26, 2022 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.