How to select a random number from a matrix

3 Ansichten (letzte 30 Tage)
shalima sudheer
shalima sudheer am 25 Apr. 2019
Beantwortet: Guillaume am 25 Apr. 2019
Hii
I have a matrix A=[2;5;3;6]
How can I select a random number from this matrix A

Antworten (1)

Guillaume
Guillaume am 25 Apr. 2019
Use randi to select an index at random:
A(randi(numel(A)))

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