from swap.m by Brice Semmens
Randomly shuffles a binary matrix while keeping row and column sums the same as the original matrix.

All files for swap.m
/swap.m

Contact us at files@mathworks.com