Filter löschen
Filter löschen

Generate random numbers from a vector

1 Ansicht (letzte 30 Tage)
Angus Wong
Angus Wong am 3 Okt. 2019
Kommentiert: Angus Wong am 3 Okt. 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.

Akzeptierte Antwort

the cyclist
the cyclist am 3 Okt. 2019
Here's one way:
A(randi(numel(A)))

Weitere Antworten (0)

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by