How to select a random number from a matrix

6 views (last 30 days)
shalima sudheer
shalima sudheer on 25 Apr 2019
Answered: Guillaume on 25 Apr 2019
Hii
I have a matrix A=[2;5;3;6]
How can I select a random number from this matrix A

Answers (1)

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

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!