필터 지우기
필터 지우기

How should I understand this code

조회 수: 3 (최근 30일)
ZhG
ZhG 2013년 6월 14일
Hello,
I have a code segment of generating gaussian noise, but I don't understand why it does so.
p=1+rand(1)*99; Gaussian_noise=rand(n,m)*(p-50);
rand(1) generates a 1-by-1 matrix from uniform distribution [0 1], right? but why it multiply a 99? And then it generate a matrix as the same size of an image I(n,m) And then subtract 50 and multiply again
Thanks.

채택된 답변

Wayne King
Wayne King 2013년 6월 14일
This does not look like it produces white Gaussian noise. For example:
n = 1000;
m = 1;
p=1+rand(1)*99; Gaussian_noise=rand(n,m)*(p-50);
hist(Gaussian_noise)
figure;
qqplot(Gaussian_noise)
Just use randn()
If you want a matrix of Gaussian white noise
X = randn(256,256);
That is zero mean, variance 1. Add a constant and scale to obtain a different mean and variance.
  댓글 수: 1
ZhG
ZhG 2013년 6월 14일
Thanks very much Wayne, but I just don't understand as well. Is this knowledge from Signal Processing.
rand(1) or rand(n,1) generates data set of uninform distribution in the interval (0,1) It multiplys 99, then it maps this interval to (0,99), right? But why it plus an extra 1? And for the second line, Gaussian_noise = rand(n,m) * (p-50), I just don't understand it completely.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Detection에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by