Random selection of n values from a vector - which function should I use?
Afficher commentaires plus anciens
I have a vector with twenty unique values from 1 to 20. I would like to select randomly two values from my vector. Which option should I use? Is there some difference between the functions attached below?
randperm
A = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20];
y = A(randperm(20,2));
randsample
y = randsample(20,2);
datasample
y = datasample(A,2);
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Stable Distribution dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!