How should I understand this code
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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.
0 commentaires
Réponse acceptée
Wayne King
le 14 Juin 2013
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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Random Number Generation dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!