I need to get some kind of matrix or array with the numbers 1 and 2 randomly distributed, but I need the number of "ones" to be the same as the number of "twos".
Therefore, I applied the randsrc function, with 50% probability for number 1 and 50% probability for number 2.
However, when I run this, sometimes I do get what I want ([1,2,2,1] or [2,1,2,1], e.g.) but many times it is wrong (e.g., [1,1,1,2] or [2,2,2,2]).
The size doesn't necessarily need to be 1x4, I'm doing that for now but it will be 1x50 once I get it to work.
Anyone knows why this is not working, what am I doing wrong or has any other idea for how to do this?
a = randsrc(1,4,[1 2;0.5 0.5]);