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!!

 Accepted Answer

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 Comments

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);

Sign in to comment.

More Answers (0)

Categories

Find more on Random Number Generation in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!