Home > Blockchain >  how to randomly assign a list of 20 names into 4 groups in matlab without repeating
how to randomly assign a list of 20 names into 4 groups in matlab without repeating

Time:01-14

I need to randomly select names from a list and randomly place them into a defined number of groups. For instance, I have 20 names in a list and I want my code to randomly pick a name and place them into one of the 4 groups till the end of the list. At the end of the code, I would like to output the names for each generated group or team.

This is what I have so far however it is not working.

data = readtable("NameList (2).xlsx");

%Check and make sure the script is accurately pulling names
Names = (data{:,1}); disp(Names)

%Arranging and Organizing Data
number_of_people = numel(data);
%Scramble array
s= number_of_people(randperm(length(number_of_people)))
number_of_groups = 4; 
divisions = sort(randperm(number_of_people-1, number_of_groups-1)   1, 'ascend')
divisions = [0, divisions, number_of_people] 

           
  •  Tags:  
  • Related