MATLAB: Coding online murder thestery, how to not repeat data

help

Hi,
Trying to split a data file into equal groups of 3, with each bit of data unique from the output. I have tried the following code(s):
[x y] = xlsread('cloodo','data');
data = y;
y1=numel(y);
for i=1:12
player(:,i) = unique(y(randperm(y1,3)));
end
and
[x y] = xlsread('cloodo','data');
data = y;
y1=numel(y);
player1 = unique(y(randperm(y1,3)));
player2 = unique(y(randperm(y1,3)));
player3 = unique(y(randperm(y1,3)));
player4 = unique(y(randperm(y1,3)));
player5 = unique(y(randperm(y1,3)));
player6 = unique(y(randperm(y1,3)));
player7 = unique(y(randperm(y1,3)));
player8 = unique(y(randperm(y1,3)));
player9 = unique(y(randperm(y1,3)));
player10 = unique(y(randperm(y1,3)));
player11 = unique(y(randperm(y1,3)));
answer = unique(y(randperm(y1,3)));
writecell(player1)
writecell(player2)
writecell(player3)
writecell(player4)
writecell(player5)
writecell(player6)
writecell(player7)
writecell(player8)
writecell(player9)
writecell(player10)
writecell(player11)
writecell(answer)
but some of the values are repeated.
Any help would be greatly appreciated

Best Answer

unique() the data. randperm() the length of the data. Throw away entries from the end of the permutation until the resulting length is a multiple of 3. reshape() what is left into groups of 3. Those are the indices.
yu = unique(y);
p = randperm(length(yu));
p = reshape(p(1:floor(end/3)*3),3);
groups = yu(p);
for K = 1 : min(11, size(groups,1))
player = groups(K,:);
filename = sprintf('player%d.txt', K);
writecell(player, filename);
end