Hi,
I want to produce a matrix of n columns that contains only 1 and 0, it should produce all possible combinations and non-repeatable. I used ff2n(n) to produce this matrix, but now I want to control the number of zeros. Cause If n=46, the ff2n(46) matrix is too big and exceeds array size preference, I need to cut the matrix. So is there any algorithm allow me to control the number of zeros in the binary matrix?
For example
ff2n(4)ans = 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1
and my desired results which contains up to two 0 are:
ans = 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 1 1 0 0 1 1 0 1 0 1 0 1 1 1 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1
How could I solve this? Could anyone help me with this please?
Best Answer