About matrix: how to make matrix binary (0 and 1)

조회 수: 11 (최근 30일)
JRC
JRC 2012년 12월 17일
댓글: Walter Roberson 2021년 8월 15일
I need write the matrix (0 0 0 0 0), (1 0 0 0 0), (1 1 0 0 0), (1 1 1 0 0),..., (1 1 1 1 1) with 32 possibilities of zero and one using the matlab, and don´t hand.
Thanks.

답변 (1개)

Matt Fig
Matt Fig 2012년 12월 17일
편집: Matt Fig 2012년 12월 17일
S = dec2bin((1:32).') % If a string is o.k.
N = S - '0' % If you need a numeric matrix.
  댓글 수: 9
Rabiya Tanveer
Rabiya Tanveer 2021년 8월 15일
helpful
Walter Roberson
Walter Roberson 2021년 8월 15일
S = (dec2bin((1:32)) - '0') * 2 - 1
S = 32×6
-1 -1 -1 -1 -1 1 -1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 1 -1 -1 -1 1 1 -1 -1 -1 -1 1 1 1 -1 -1 1 -1 -1 -1 -1 -1 1 -1 -1 1 -1 -1 1 -1 1 -1

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by