Borrar filtros
Borrar filtros

Generate random numbers from a vector

1 visualización (últimos 30 días)
Angus Wong
Angus Wong el 3 de Oct. de 2019
Comentada: Angus Wong el 3 de Oct. de 2019
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 Get Started with MATLAB en Help Center y File Exchange.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by