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.

 Respuesta aceptada

the cyclist
the cyclist el 3 de Oct. de 2019
Here's one way:
A(randi(numel(A)))

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Versión

R2019b

Preguntada:

el 3 de Oct. de 2019

Comentada:

el 3 de Oct. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by