Generate random numbers from a vector

I would like Matlab to give me a number from a given row vector, such as:
A=[1 3 5 9 100 150 658 999];
Matlab would either give me 1,3,5,9,100,150,658, or 999 in a random manner.(Only one output.)
How can I do this? Many thanks.

 Accepted Answer

Here's one way:
A(randi(numel(A)))

More Answers (0)

Categories

Products

Release

R2019b

Community Treasure Hunt

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

Start Hunting!