I am generating a random vector of size 1×50 (using randi with range 1 to 400),several times(lets say 50000 times). But from these random vectors, I will chose only those vectors which does not contain more than two identical elements i.e. a vector having more than two identical elements will be thrown and rest will be saved in row wise matrix form. How to do this generally so that I can use the code for other cases(e.g. not more than four identical elements instead of two etc.)
MATLAB: Chose vectors (from a randomly generated vectors) which does not contain more than two identical elements
identical elementsrandom vector
Best Answer