dear all:I have a 6* 3 matrix. I wanna choose 4rows randomly. how can I selecete all array in a rows randomly without replacement?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
fariba amini
le 27 Juil 2016
Commenté : fariba amini
le 27 Juil 2016
for example:
A=[1 2 3;2 3 5;6 4 1;8 6 0;2 4 1;1 4 7;8 4 2];
and the answer is:
[1 2 3;6 4 1;8 6 0;8 4 2];
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 27 Juil 2016
Modifié(e) : Azzi Abdelmalek
le 27 Juil 2016
A=[1 2 3;2 3 5;6 4 1;8 6 0;2 4 1;1 4 7;8 4 2]
B=A(randperm(6,4),:)
4 commentaires
Azzi Abdelmalek
le 27 Juil 2016
Modifié(e) : Azzi Abdelmalek
le 27 Juil 2016
idx=sort(randperm(6,4))
B=A(idx,:)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MATLAB 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!