How do i add normal error to some ideal values ?

Hello,
I have a set of ideal -error free- measurements and i want to add some error to them to simulate measurement error (noise etc). I want to know how to add an error with a known standard deviation.
X is the ideall measurements. σ is the standard deviation of the error measurement - known e - error
Xreal = X + e
Xreal = X + σ^2*randn(1) ?
this is not right becouse i will have only positive errors...
please help needed!!

 Réponse acceptée

Wayne King
Wayne King le 2 Juin 2012
Assume x is your error-free data
x = cos(pi/4*(0:99));
% now add the error, let the standard deviation be 2
x = x+ 2*randn(size(x));
You do not want to multiply randn() by the variance, you multiply by the standard deviation.

2 commentaires

Valeriu
Valeriu le 2 Juin 2012
Thanks a lot for the answer!!
Is there any difference between using randn as above or using random? For example, using the same items from above:
x = random('norm', x, 2);

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Random Number Generation dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by