MATLAB: Constuctiing special array (like binary)

arraybinary

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!!

Best Answer

  • dec2bin(0:2^n-1)-'0'