フィルターのクリア

How can I randomly select one variable between 3 variables?

3 ビュー (過去 30 日間)
Hwajin Choi
Hwajin Choi 2022 年 2 月 28 日
コメント済み: Hwajin Choi 2022 年 2 月 28 日
I want to randomly select 1 variable between variables 10, 20, and 30.
This is what I did and it failed.
a = [10:10:30]
rand(a)
It gives me numerous floats. I want to get 10 or 20 or 30.
Thank you for your help.

採用された回答

Fangjun Jiang
Fangjun Jiang 2022 年 2 月 28 日
a = [10:10:30]
a(randi(3,1))

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by