How to add noise in [0 2] interval to an elements of an array randomly?
12 次查看(过去 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(:);
采纳的回答
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;
0 个评论
更多回答(1 个)
Christopher McCausland
2022-4-12
编辑:Christopher McCausland
2022-4-12
6 个评论
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 Center 和 File Exchange 中查找有关 Link-Level Simulation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!