i have a vector which contain 23 elements.i wanna choose 20 elements among this 23 elements randomly.how can i do this?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
fariba amini
le 19 Avr 2016
Commenté : fariba amini
le 19 Avr 2016
i have a vector which contain 23 elements.i wanna choose 20 elements among this 23 elements randomly.how can i do this?
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 19 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 19 Avr 2016
A=randi(50,1,23)
out = A(randperm(23,20))
3 commentaires
Azzi Abdelmalek
le 19 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 19 Avr 2016
out = A(sort(randperm(23,20)))
Plus de réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!