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

조회 수: 9 (최근 30일)
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
Ayberk Ay
Ayberk Ay 2022년 4월 12일
Actually it doesn't. Any noise could be fine.
Ayberk Ay
Ayberk Ay 2022년 4월 12일
I've tried something but not sure it is exact true.
sigmas = 2;
randomNoise = randn(length(r1), 1)*sigmas+a;
r11 = r1 + randomNoise;

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2022년 4월 12일
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;

추가 답변 (1개)

Christopher McCausland
Christopher McCausland 2022년 4월 12일
편집: Christopher McCausland 2022년 4월 12일
Hi Ayberk,
Have you tried awgn(r1)?
r1Gaus = awgn(r1);
Kind regards,
Christopher
  댓글 수: 6
Ayberk Ay
Ayberk Ay 2022년 4월 12일
Yes, that's what i was looking for. Thanks for the answer.
Christopher McCausland
Christopher McCausland 2022년 4월 12일
No worries,
I am glad to be of help! If you could accept this answer that would be fantastic!
Christopher

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by