MATLAB Answers

How to draw (random or with certain chance) multiple elements from a set where the element must not be equal to each other

2 views (last 30 days)
n = 10
m = 3
strategies = zeros(n,m)
V = [1 2 3 4 5 6]
I want to draw m numbers from V n times, where strategies(i,1) strategies(i,2) and strategies(i,3) may NOT be equal so a good solution for example strategies(i,:) = [1 6 4] bad solution = strategies(i,:) = [1 6 1] (cause there are two ones
pseudo code:
for i = 1:n
for j = 1:m
strategies(i,j) = random(V)
strategies(i,1) isnot strategies(i,2) isnot strategies(i,3)
end
end
good answer would be
1 3 4
4 5 6
6 1 3
3 5 6
2 1 4
etcccc
I Hope somebody can help me! (and sorry for bad englisch)
extra: if somebody know how to draw with a certain chance each element of V that would be awesome to

  0 Comments

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!