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