How to set WaitSecs for several durations?

I would like to set WaitSecs for several duration such as 1.0s, 1.5s, and 2.0, and randomize them.
How should I write a code?
rs = randperm(3);
WaitSecs(?);

 採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 20 日

0 投票

Try this
rs = [1.0 1.5 2.0];
idx = randi(numel(rs));
WaitSecs(rs(idx))

2 件のコメント

Takara Sumoto
Takara Sumoto 2020 年 10 月 20 日
Thank you, it worked!
Ameer Hamza
Ameer Hamza 2020 年 10 月 20 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by