How can I randomly extract a element in a vector?

6 ビュー (過去 30 日間)
Ana Gabriela Guedes
Ana Gabriela Guedes 2020 年 4 月 6 日
Hi!!
How can I extract a random element from a vector?
For example, I have vector v = [a1 a2 a3 a4] and I want to randomly select one of the elements. ~
Thanks!!

採用された回答

Torsten
Torsten 2020 年 4 月 6 日
編集済み: Torsten 2020 年 4 月 6 日
random_element = v(randi(numel(v)))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRandom Number Generation についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by