Info

此问题已关闭。 请重新打开它进行编辑或回答。

hi,I wanted to know, how can i generate a 3 bit sequential binary vector with up to only ONE 1?

1 次查看(过去 30 天)
Eg: 001, 010,100

回答(1 个)

John D'Errico
John D'Errico 2017-8-17
编辑:John D'Errico 2017-8-17
Up to only ONE 1 means the number is any number (in decimal) from the set [0,1,2,4].
Pick an element at random from that set. Then convert to binary.
help dec2bin

此问题已关闭。

Community Treasure Hunt

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

Start Hunting!

Translated by