random number generator to two different variables
조회 수: 5 (최근 30일)
이전 댓글 표시
I want to initialize two different random numbers to be assigned to different variables. If I put in:
x_1 = rand x_2 = rand
they will get exactly the same number. How do I assign two different random numbers?
Thanksr
댓글 수: 0
채택된 답변
Shane
2014년 11월 25일
They get different random numbers for me. Which version of Matlab are you using?
댓글 수: 4
Shane
2014년 11월 25일
You may look into this: http://www.mathworks.com/help/matlab/math/why-do-random-numbers-repeat-after-startup.html
추가 답변 (1개)
Peter Perkins
2014년 11월 25일
cgo, it may be that you have created a variable called "rand" in your workspace that is shadowing the rand function. The rand function does not return the same value two times in a row within the same MATLAB session.
댓글 수: 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!