Constuctiing special array (like binary)
1 view (last 30 days)
Show older comments
Dimitris Sideratos
on 4 Dec 2013
Commented: Dimitris Sideratos
on 21 Jan 2014
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 Comments
Accepted Answer
More Answers (3)
Andrei Bobrov
on 4 Dec 2013
Edited: Andrei Bobrov
on 4 Dec 2013
rem(floor((0:pow2(n)-1)'*pow2(1-n:0)),2)
Jos (10584)
on 20 Jan 2014
Edited: Jos (10584)
on 20 Jan 2014
Take a look at COMBN:
USe like this:
N = 2 ; M = 3 ;
combn(0:M-1,N)
See Also
Categories
Find more on Argument Definitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!