how to generate 2^16 different combinations of a vector containing 0 and 1 only?
1 次查看(过去 30 天)
显示 更早的评论
Hello all,
I would like to generate 2^16 different combinations of 16 bits containing 0s and 1s. I have tried different ways like using nchoosek,... but I have the out of memory error. Could somebody please propose a more efficient way? Thank you!
1 个评论
James Tursa
2015-12-9
Please explain the problem you are working and why you think you need this matrix in memory all at once.
采纳的回答
the cyclist
2015-12-9
As a character array:
dec2bin(0:2^15-1)
As a numeric matrix of 1s and 0s:
dec2bin(0:2^15-1) - '0'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!