MATLAB: How to add white gaussian noise with variance 1 to a signal and calculate the signal-to-noise ratio

white gaussian noise

Hi. I have a signal that I want to add white gaussian noise to. The variance of the white gaussian noise is 1. Then I will pass it to a low pass filter. Hence, I want to find out the signal-to-noise ratio at both input and output.
After some googling, I understand that I need to use awgn or wgn to add white gaussian noise to the signal. However, I'm getting quite confused with awgn which takes in the signal and signal-to-noise ratio and for wgn, which takes in the M-by-N matrix and power of the noise in dB. I do not have any of the variables and only know that the variance of the white gaussian noise should be 1. Does anyone know how I can add white gaussian noise to the signal? I think I might need to use randn but is not very sure how I can use it.
Can someone help me out?

Best Answer

Just use randn()
t = 0:0.001:1;
x = cos(2*pi*100*t)+randn(size(t));
To use a different variance, multiply randn() by the square root of the variance
For example, for a variance of 2
noisevec = sqrt(2)*randn(1000,1);
Related Question