Shuffling elements of an array!!

조회 수: 45 (최근 30일)
Abhishek Vashishtha
Abhishek Vashishtha 2020년 6월 23일
댓글: madhan ravi 2020년 6월 23일
Hi Guys,
I have assigned a vector like this:
lottery = [ 1 , 3 , 4 , 5 , 2 ];
I wanted to shuffle it in randomized array, please let me know how should I do it

채택된 답변

Ashish Azad
Ashish Azad 2020년 6월 23일
Hi Abhishek,
This question is answered earlier too,
meanwhile I will provide with the answer too,
try to use: lottery(randperm(length(lottery)))
randperm(n) will create a randomized vector of length n containing all the values from 1 to n in randomized manner
Please read documentation for further asist
This should work!!
  댓글 수: 1
madhan ravi
madhan ravi 2020년 6월 23일
Providing a complete homework solution is discouraged in this forum.

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

추가 답변 (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