简体   繁体   中英

Matlab: Generate noisy signal for particular SNR and particular variance

In general when we add noise to a signal x=rand(1,100) , this is one way

 sigma_2_v = 0.5;
noisy_signal = rand(1,100) + sqrt(sigma_2_v)*randn(1,100);

There is another method found here: Proper way to add noise

For my case, I need to have the information about the variance of the noise, sigma_2_v , and generate noisy signal by varying sigma_2_v . How can I do that?

There are a number of possible conventions used to define as/n ratio, a common one being based on the notion of signal and noise power. If the total power of the spectrum is p and the noise power is np , then the signal-to-noise can be written as snr = p - np , when the power is in dB units, or snr = p/np , when the power is in linear units.

The MATLAB (and Octave equivalent) function awgn adds (white Gaussian) noise to an input data array to the desired final s/n power level, specified by default in dB. The function awgn uses another function wgn to generate an array representing the noise at a desired noise power level. The noise is sampled from a Gaussian distribution (it is not rescaled to make the variance of the points in the array equal exactly the desired noise power level, as some suggest you do ; do not rescale the noise: if you rescale the points sampled from the noise distribution, then the points will (obviously) not necessarily reflect the desired noise distribution or the desired power level!). You can specify the amount of noise to add to your data via awgn in a number of non-default ways, for instance: a) by specifying the power of the input data (the default is 0 dB), or b) by asking the routine to compute the power of the input data using the formula p = var(data,1) , where var(...,1) implies computation of the population variance. In either case the routine computes the required noise power level using the formula np = p-snr (in dB).

The excellent MATLAB documentation provides a good description of the awgn routine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM