MATLAB: Generating a random binary matrix with conditions

matrixrandom number generator

Hello
I have written the following line of code to generate a random binary matrix
Pop = round(rand(5,5))
It works fine in most cases however sometimes i get columns with all zeros, how do i avoid getting all zeros in any of the column.

Best Answer

Just throw those columns away, if you get any like that, and replace them with new samples. WTP?