so i have a cell array with names of people and i want to make a function that generate random groups out of those names.
i want to make it so that grouping{1} in main function would return first group randomly chosen
i have 22 people and if i want to separate into 6 groups, i want 4 groups of 4 people and 2 groups of 3 people.
i have a main function that defines cell array defined as Identifiers that contains all 22 people names as character.
i'm not sure how to use that Identifiers into this function below. this is how far i have. this only returns array with empty 6 cells like {1×4 double}.
function grouping = generate_random_grouping(number_of_people, number_of_groups) randorder = randperm(number_of_people); %shuffle the people
split = repmat(floor(number_of_people / number_of_groups), 1, number_of_groups); %how many in each group?
toincrease = mod(number_of_people, number_of_groups); %how many groups need an extra element
split(1:toincrease) = split(1:toincrease) + 1; grouping = mat2cell(randorder, 1, split);end
Best Answer