addnoise
Synopsis

Adds noise to a signal.

yn = addnoise(y,SNR)
yn = addnoise(y,SNR,NoiseModel)
Description

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 level is chosen based on that and on SNR.

The model for the noise is given in NoiseModel and is either 'u' (the default), a uniform distribution between -0.5 and +0.5 times the noise level, or 'n', a normal (Gaussian) distribution with a standard deviation equal to the noise level.

Examples

Here is how to add noise to a Gaussian line:

x = linspace(-1,1,1001);
y = gaussian(x,0,0.3);
yn = addnoise(y,10);
See also

smooth