How can I choose one element form a row array randomly?

Good morning, I'm interested in choosing only one element from an array. e.g. i got the following array T=[0 1 2 3 4 5] but I want to get one element from it randomly. Thanks for your attention.

 採用された回答

James Tursa
James Tursa 2018 年 5 月 17 日
編集済み: James Tursa 2018 年 5 月 17 日

2 投票

result = T(randi(numel(T)));

1 件のコメント

Luis Bernardo de la Merced
Luis Bernardo de la Merced 2018 年 5 月 17 日
Thank you very much, it worked perfectly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by