# doubt reg adding randn function to a sinusoidal signal to get noisy time domain signal

Started by March 2, 2009
I saw a code in mathworks.com which analyses the freq components of noisy time domain
signal by explicitly plotting power Vs freq
fs00;     % sampling freq
T=1/fs;       %sample time
L00;      % signal length
t=(0:L-1)/T;     %time vector
x=0.7*sin(2*pi*50*t)+sin(2*pi*120*t);   % i/p signal i.e., two sinusoids were added
Now , we have noisy time domain signal
by corrupting the i/p signal x with zero mean random noise
MATLAB CODE:
noise_sig = original_sig + std_dev*randn(size(original_sig));
y=x+2*randn(size(t));  %sinusoids corrupted with zero mean random noise

here in the above line : why 2 has been inserted (which is the value of std deviation)
(I guess since two sinusoids has been involved & added )
instead it should be y=x+1*randn(size(t)); (so that var=std deviation=1)
can any one explain about the inclusion of 2.
Thank you
Thank you sir for explaning me elaboratly. i understood.
But the last line U wrote:
"I would set y = x + sqrt(10^(-SNR_dB))* noise. Where the noise must have noise power = signal_power."

I cant get the point which you have specified.and i cant trace out how did you introduce negative sign in that line i.e., 10^( - SNR_dB))*

I think, having known the signal power in advance which is (1/2)*(0.7^2 + 1^2) = 0.7450= Ps = Signal power
since,
10log10(Ps/Pn)=SNR_dB
Pn= Noise power = Ps/10^(SNR_dB/10) = sigma^2= Variance of zero mean random gaussian noise.
as sigma=root mean square value provided mean is zero.= sqrt(Pn)= std. deviation

can i set 'y' as y = x + [sqrt( Ps/10^(SNR_dB/10) ) * randn(size(original_sig)) ] ;

is it correct sir?
sorry I had a typo...it should be sqrt(10^(-SNR_dB/10)). I missed the
divide by 10. And yes, what you have will also work. In your case, you are
folding in Ps in the noise scaling. In my case (after correcting the typo),
my Ps is folded into the noise term and my scaling is only for the SNR.

On Tue, Mar 3, 2009 at 11:10 PM, T.E Ravi wrote:

> Thank you sir for explaning me elaboratly. i understood.
> But the last line U wrote:
> "I would set y = x + sqrt(10^(-SNR_dB))* noise. Where the noise must have
> noise power = signal_power."
>
> I cant get the point which you have specified.and i cant trace out how did
> you introduce negative sign in that line i.e., 10^( - SNR_dB))*
>
> I think, having known the signal power in advance which
> is (1/2)*(0.7^2 + 1^2) = 0.7450= Ps > Signal power
> since,
> 10log10(Ps/Pn)=SNR_dB
> Pn= Noise power = Ps/10^(SNR_dB/10) = sigma^2= Variance of zero mean random
> gaussian noise.
> as sigma=root mean square value provided mean is zero.= sqrt(Pn)= std.
> deviation
> can i set 'y' as y = x + [sqrt( Ps/10^(SNR_dB/10) ) *
> randn(size(original_sig)) ] ;
> is it correct sir?