how to randomly select an element in a matrix

1 visualizzazione (ultimi 30 giorni)
Hi,
I have a matrix for example A = [1,2,3,4,5,6]; I would like to randomly select an element in A.
How do I do that?

Risposta accettata

Walter Roberson
Walter Roberson il 19 Ott 2015
A(randi(numel(A)))

Più risposte (0)

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