I've wrote a very clear and simple code to understand:
mat5x5 = rand(5);
chanse_of_1s=.90% probability for 1s, just change it.
chanse_of_0s=.10% probability for 0s, just change it.
mat5x5 = arrayfun(@(x)sum(x >= cumsum([0, chanse_of_0s, chanse_of_1s])), mat5x5)-1
just chage the chanses!