how to randomly select an element in a matrix

4 views (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 19 Oct 2015
A(randi(numel(A)))

More Answers (0)

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!