Generating random integers in MATLab

조회 수: 1 (최근 30일)
Ajay Kumar
Ajay Kumar 2018년 12월 25일
댓글: madhan ravi 2018년 12월 25일
Can anyone please tell me on how to generate random inters every time my program passes through the loop.
I need 20 nodes between the coordinates of 0-100
during each iterations 20 nodes have to be created at random coordinates.

채택된 답변

madhan ravi
madhan ravi 2018년 12월 25일
randi([0 100],1,20)
  댓글 수: 2
John D'Errico
John D'Errico 2018년 12월 25일
+1, but remember that this generates integers with replacement. So if you cannot tolerate replicates, then you need to use other tools. Randperm can do it without replacement, so if you want them including 0 up to 100, do this:
randperm(101,20) - 1
madhan ravi
madhan ravi 2018년 12월 25일
Thank you @John D'Errico completely agree..

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by