# snr of awgn in matlab before and after filtration

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:

K0=1.2;
b=[0 K0];
a=[1 K0-1];
N=10000;
n=1:N;
uinp=[1 ones(1,N-1)];
sn=0   ;               % SNR on input signal
levs=0  ;
uinp=awgn(uinp,sn,levs);
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


What about the MATLAB SNR Function?

• 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 Oct 25, 2022 at 4:07
• There's a lot to unpack here. My advice is to run the examples that MATLAB provides for awgn() and snr().
– user58975
Oct 25, 2022 at 4:41
• I've did it using snr(signal,noise), where signal is if filter signal without noise, and noise is filter noisedSignal-clearSignal Oct 26, 2022 at 14:11