How to randomly generate two integers for N number of times?

1 回表示 (過去 30 日間)
J Vard
J Vard 2018 年 1 月 20 日
コメント済み: J Vard 2018 年 1 月 20 日
I want to generate -1 and 1 randomly, for as many times I want. I am using it to develop a code for 1D walk model. Thanks

採用された回答

James Tursa
James Tursa 2018 年 1 月 20 日
E.g., for n samples
walk = 2*(rand(1,n)>0.5) - 1;
  2 件のコメント
J Vard
J Vard 2018 年 1 月 20 日
Hi!! Thanks for the answer. Please explain the 0.5 in that
J Vard
J Vard 2018 年 1 月 20 日
Got it!. Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by