필터 지우기
필터 지우기

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
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
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 CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by