# AWGN Build vs Randn noise do not match

I am generating noise in two different cases with the same SNR once using AWGN command which is a built in command and second time using randn function with the correct scaling however I am getting different noise power in each case.

Following is the script to generate noise using different techniques. Can anyone help me why I am not getting the correct result?

Method 1

  A=[1-1i 1+1i 2-1i 2+1i  3+1i  3-3i]
Norm=sum(abs(A).^2)/length(A);
flipud(A);
snrdb=0;
snrlin=10^((snrdb)/10);
Noise=sqrt(Norm/(2*snrlin))*(randn(size(A,1),size(A,2))+1i*randn(size(A,1),size(A,2)));


Method 2

B=awgn(A,snrdb,'measured');
Noise2=B-A;


The result is as follow:

>> sum(abs(C).^2)/length(C)

ans =

3.6551

>> sum(abs(Noise).^2)/length(Noise)

ans =

6.4898


Power of signal is

>> sum(abs(A).^2)/length(A)

ans =7


This seems that randn does better job in estimating the power of signal and awgn this case but in different cases the results are varying and might get different result. Can anyone tell me how I can change my code that both noise generate using built in command and randn gives me the same result.

• where did C come from? your code isn't complete – Stanley Pawlukiewicz Jul 13 '17 at 21:37