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

3 ビュー (過去 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 Center および File ExchangeData Type Conversion についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by