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.

类别

帮助中心File Exchange 中查找有关 Random Number Generation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by