So basically what i want to generate is a 3 number combination with repetition. So, for example, The range of the number is from 1 to 31, and i have 3 sets. So assume that for the 1st set i randomly pick number 2, then for the 2nd set i randomly pick 12, the for the 3rd set, i randomly pick 31. Then i will have 3 combination 2,12,and 31. And i want to do this with N trials.
I tried to use this code:
Y = zeros(3,31);
for i=1:1000
Y(i,:) = randperm(31);
end
Y = Y(:, 1:3);
However, this code is for combination WITHOUT repetition. What i need is combination WITH repetition.
Please help me out!
Thank you!
Aucun commentaire:
Enregistrer un commentaire