Exclude negative values from random number generator
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
Walter Roberson
2012-2-6
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 !
0 个评论
更多回答(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!