how to randomly select an element in a matrix

1 Ansicht (letzte 30 Tage)
cgo
cgo am 19 Okt. 2015
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?

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Okt. 2015
A(randi(numel(A)))

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by