Effacer les filtres
Effacer les filtres

Generate random numbers from a vector

1 vue (au cours des 30 derniers jours)
Angus Wong
Angus Wong le 3 Oct 2019
Commenté : Angus Wong le 3 Oct 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.

Réponse acceptée

the cyclist
the cyclist le 3 Oct 2019
Here's one way:
A(randi(numel(A)))
  1 commentaire
Angus Wong
Angus Wong le 3 Oct 2019
Thank you for the quick response!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by