Adds noise to a signal.
yn = addnoise(y,SNR,NoiseModel)
This functions adds noise to a given signal y
to give the noisy signal yn
. The target signal-to-noise ratio is specified in SNR
.
The signal amplitude is estimated from the difference of the maximum and the minimum value of the signal y
, and the noise amplitude is set such that the ratio of the signal amplitude to the noise standard deviation gives the number requested in SNR
.
The model for the noise is given in NoiseModel
. Possible values are:
'f'
, a simple 1/f noise model,
'u'
a uniform distribution,
'n'
, a normal (Gaussian) distribution.
addnoise
works on 1D and 2D data sets.
Here is how to add noise to a Lorentzian line:
x = linspace(-1,1,1001); y = lorentzian(x,0,0.3); yn = addnoise(y,20,'n');