How to add noise in [0 2] interval to an elements of an array randomly?

7 views (last 30 days)
I have an array that is called 'r1' and i need a white noise to add to elements of the array. Every noise that is gonna to be added to elements should be different (like randomly) in [0,2] interval.
a = 0;
b = 360;
rng('shuffle');
ncycles = 10;
npoints = 500000;
r1 = sort((b-a)*rand(npoints/ncycles,ncycles)+a,1,'ascend');
r1 = r1(:);
  3 Comments
Ayberk Ay
Ayberk Ay on 12 Apr 2022
I've tried something but not sure it is exact true.
sigmas = 2;
randomNoise = randn(length(r1), 1)*sigmas+a;
r11 = r1 + randomNoise;

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 12 Apr 2022
I'd do it like this
noiseSignal = 2 * rand(size(r1));
r1WithNoise = r1 + noiseSignal;
If you want + or - 1 instead of adding noise, which will bias the signal upwards you can do:
noiseSignal = 2 * rand(size(r1)) - 1;
r1WithNoise = r1 + noiseSignal;

More Answers (1)

Christopher McCausland
Christopher McCausland on 12 Apr 2022
Edited: Christopher McCausland on 12 Apr 2022
Hi Ayberk,
Have you tried awgn(r1)?
r1Gaus = awgn(r1);
Kind regards,
Christopher
  6 Comments
Christopher McCausland
Christopher McCausland on 12 Apr 2022
No worries,
I am glad to be of help! If you could accept this answer that would be fantastic!
Christopher

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!