How does one generate a random matrix that satisfies certain properties? Specifically, I'm looking for a code that does this:
Given the matrix below, I want to randomly change the locations of 1s.
1 0 0 1 0 00 0 00 0 0
So examples would be
1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 0 0 0 0 0
Well the initial matrix is easy enough.
A = zeros(4,3);A(1:2,1) = ones(2,1);
But I don't know how to proceed from here. randperm() only generates a vector so doesn't work here. Is there a matlab function that does what randperm does on a matrix?
Best Answer