random entry selection from a matrix
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
how can I select any element randomly from a 1 x n matrix?
0 Commenti
Risposte (1)
Doug Hull
il 23 Lug 2012
v = [1:10]
vi = randi(numel(v));
choice = v(vi)
1 Commento
Walter Roberson
il 23 Lug 2012
Doug, you missed your chance to say
choice = v(randperm(numel(v),1));
Vedere anche
Categorie
Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!