How to choose 5 random rows from an array of 8 rows for 10 times and save the 10 results

1 vue (au cours des 30 derniers jours)
Hi suppose I have an array of 8 rows as below:
I wish to choose 5 random rows 10 times
Suppose 6,4,8,7,2 is the first random result, how do I save row 6,4,8,7,2 as a input result so that I do not have a different first result if I wish to run the program next time again. And similarly apply it for the rest of the 9 results.

Réponse acceptée

J. Alex Lee
J. Alex Lee le 4 Mar 2020
Modifié(e) : J. Alex Lee le 4 Mar 2020
if order doesn't matter (6,4,8,7,2 is the same as 4,6,8,7,2)
doc nchoosek
if order does matter (6,4,8,7,2 is different from 4,6,8,7,2)
doc perms
  2 commentaires
tinkiewinkie
tinkiewinkie le 4 Mar 2020
i tried nchoosek(1:8,5) and it gave me the combination of all possible 56 combination. How do I choose 10 random combination and saved it as a fixed result?
J. Alex Lee
J. Alex Lee le 4 Mar 2020
NumRows = 10
rowindices = randperm(nchoosek(8,5),NumRows)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Elementary Math dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by