So what I am trying to do is simply select random '1' element from logical matrix in matlab. Suppose I have a matrix like this:
A= 0 1 1 1 0
0 1 0 1 1
1 0 0 0 0
0 0 1 0 0
0 0 0 0 0
and I have a number n which is a number that represent how many '1' elements will be selected in the procedure
For example if n=3
then the output can be looks like this:
A'= 0 1 0 0 0
0 0 0 0 1
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
*note that the maximum value possible for n is the number of '1' elements in matrix being processed