Constuctiing special array (like binary)
Ältere Kommentare anzeigen
Hi, I'am new to matlab and I want to make an nxn matrix containing as first row zeros and as last row ones. The other rows should be like binary digits.
Example with n=4:
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
Thank you!!
2 Kommentare
Matt J
am 4 Dez. 2013
The matrix you've shown is not nxn. It is 2^n x n.
Dimitris Sideratos
am 5 Dez. 2013
Akzeptierte Antwort
Weitere Antworten (3)
Andrei Bobrov
am 4 Dez. 2013
Bearbeitet: Andrei Bobrov
am 4 Dez. 2013
rem(floor((0:pow2(n)-1)'*pow2(1-n:0)),2)
Dimitris Sideratos
am 19 Jan. 2014
0 Stimmen
2 Kommentare
Jan
am 19 Jan. 2014
Please open a new thread for a new question.
Dimitris Sideratos
am 20 Jan. 2014
Jos (10584)
am 20 Jan. 2014
Bearbeitet: Jos (10584)
am 20 Jan. 2014
Take a look at COMBN:
USe like this:
N = 2 ; M = 3 ;
combn(0:M-1,N)
1 Kommentar
Dimitris Sideratos
am 21 Jan. 2014
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!