How do I pick a number from a set of random numbers?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have generated numbers 1 through 52 in a random order. Next I have to pick a position and get what number is in that position but I cant do it.
What is a positive integer?
52
n =
52
p =
Columns 1 through 21
23 41 17 36 9 31 4 18 46 34 11 29 39 14 52 20 43 26 42 30 28
Columns 22 through 42
48 32 47 21 19 38 27 2 13 37 49 12 44 33 50 1 24 51 16 35 15
Columns 43 through 52
8 10 6 5 25 3 7 45 40 22
4 Kommentare
Antworten (1)
Steven Lord
am 25 Sep. 2022
Since I suspect this is part of a homework assignment I'm not going to give you the answer, but I will point you toward two functions that may be of interest to you. Take a look at the documentation pages for randperm and randi. Which one you want to use will depend on whether you want to draw cards without replacement (randperm) like you're dealing out a poker hand or with replacement (randi) like if a stage magician asks you to draw a card, look at it, and return it to the deck.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Function Creation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!