I want to generate a random array of 8 integers within [1,4] where each integer appears exactly twice. Examples:
1 1 2 2 3 3 4 44 2 1 2 3 1 3 42 4 1 2 3 4 3 1
I know randi(4,8,1) gives a random array of 8 integers within [1,4] but it does not specify how many come from which integer. Is there a built in matlab function that does this? If not, what should I do?
Best Answer