How can I randomly extract a element in a vector?

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 日

0 投票

random_element = v(randi(numel(v)))

その他の回答 (0 件)

カテゴリ

ヘルプ センター および 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