How can i add 20% additive guassian noise to each and every element of vector
조회 수: 20 (최근 30일)
이전 댓글 표시
Suppose i have a fixed value vector a=[1.05;0.2561;.3321]). I want to add 20% Gaussian noise to each value of this vector as follows:
a_with_noise=[a]+[20% Gaussian noise]=====> This should give me; a_with_noise=[1.05+noise;0.2561+noise;.3321+noise]
Here [a] should act as the mean of the Gaussian noise distribution.
Thanks
댓글 수: 0
채택된 답변
Image Analyst
2016년 5월 14일
There is a function called randn() that you must have overlooked when you were searching for "random" in the help. Use that. It gives noise with zero mean and unit standard deviation so you'll have to scale it:
% Define our signal - a column vector.
a=[1.05;0.2561;.3321]
% Make the spread of the Gaussians be 20% of the a values
sigmas = 0.2 * a % Also a column vector.
% Create the noise values that we'll add to a.
randomNoise = randn(length(a), 1) .* sigmas
% Add noise to a to make an output column vector.
output = a + randomNoise
댓글 수: 0
추가 답변 (1개)
Bjorn Gustavsson
2016년 5월 14일
If I get you right this should do it:
function A_p_noise = addgaussiannoise(A,N2S)
A_p_noise = A.*(1+N2S*randn(size(A)));
HTH
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Random Number Generation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!