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

3 Ansichten (letzte 30 Tage)
JRC
JRC am 17 Dez. 2012
Kommentiert: Walter Roberson am 15 Aug. 2021
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.

Antworten (1)

Matt Fig
Matt Fig am 17 Dez. 2012
Bearbeitet: Matt Fig am 17 Dez. 2012
S = dec2bin((1:32).') % If a string is o.k.
N = S - '0' % If you need a numeric matrix.
  9 Kommentare
Rabiya Tanveer
Rabiya Tanveer am 15 Aug. 2021
helpful
Walter Roberson
Walter Roberson am 15 Aug. 2021
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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by