필터 지우기
필터 지우기

Create a random array with specified conditions

조회 수: 1 (최근 30일)
luca
luca 2019년 9월 2일
편집: madhan ravi 2019년 9월 2일
Hi,
I would like to create a random array S where the random generation has to consider that we want to obtain a couple of number generated each time, and the couple must have the same number. It means that if I want to generated random number between 1 and 20, every time I generate X in the vector S I want the value X reported two times consecutive [X X].
ex: S = [1 1 5 5 9 9 17 17 18 18 15 15]. So the length of the random number generated should occupied two column each time.
Do you know if the command randperm may contain this option? 'Cause in my code I use randperm.
Thanks

채택된 답변

madhan ravi
madhan ravi 2019년 9월 2일
편집: madhan ravi 2019년 9월 2일
s = randperm(20,6); % example random generated vector
repelem(s,2)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by