Azzera filtri
Azzera filtri

random entry selection from a matrix

1 visualizzazione (ultimi 30 giorni)
Peter D
Peter D il 23 Lug 2012
how can I select any element randomly from a 1 x n matrix?

Risposte (1)

Doug Hull
Doug Hull il 23 Lug 2012
v = [1:10]
vi = randi(numel(v));
choice = v(vi)
  1 Commento
Walter Roberson
Walter Roberson il 23 Lug 2012
Doug, you missed your chance to say
choice = v(randperm(numel(v),1));

Accedi per commentare.

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!

Translated by