Azzera filtri
Azzera filtri

Generate random numbers from a vector

1 visualizzazione (ultimi 30 giorni)
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.

Risposta accettata

the cyclist
the cyclist il 3 Ott 2019
Here's one way:
A(randi(numel(A)))

Più risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by