Exclude negative values from random number generator
조회 수: 3 (최근 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!