How to select a random number from a matrix

6 vues (au cours des 30 derniers jours)
shalima sudheer
shalima sudheer le 25 Avr 2019
Hii
I have a matrix A=[2;5;3;6]
How can I select a random number from this matrix A

Réponses (1)

Guillaume
Guillaume le 25 Avr 2019
Use randi to select an index at random:
A(randi(numel(A)))

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by