Using Rand to generate binary encoded as +/- 3 volts
古いコメントを表示
I need to generate 100,000 numbers that have a .5 chance of being either a +3 or a -3. I already have my code being T = rand(1,10000) <= 0.5 and I am getting 1s and 0s. How do I turn these 1s and 0s into +/-3.
回答 (2 件)
Azzi Abdelmalek
2014 年 4 月 14 日
T = 6*(rand(1,10000) <= 0.5)-3
Image Analyst
2014 年 4 月 14 日
編集済み: Image Analyst
2014 年 4 月 14 日
Why not just use randi instead:
T = 6*(randi(2, 10000, 1) - 1) - 3
カテゴリ
ヘルプ センター および File Exchange で Random Number Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!