Effacer les filtres
Effacer les filtres

Exclude negative values from random number generator

3 vues (au cours des 30 derniers jours)
Ying
Ying le 6 Fév 2012
Hi, Just a quick question.
I generate a series of normally distributed random numbers with mean 1.5 and standard deviation 0.3.
d1 = 1.5 + 0.3.*randn(100,1)
Anyone know how I can exclude all the negative results?
Thanks a lot!
Ying

Réponse acceptée

Walter Roberson
Walter Roberson le 6 Fév 2012
d1(d1 < 0) = [];
Note that the result will not be a normal distribution and will not have mean 1.5 or standard deviation 0.3 !

Plus de réponses (0)

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!

Translated by