can anybody help me to execute the following code
Info
This question is closed. Reopen it to edit or answer.
Show older comments
numUsers = diag([1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]);
N_UE = 1 : numUsers
% Get a scrambled array
s = N_UE(randperm(length(N_UE)))
numGroups = 5; % Need to divide s up into 5 groups
divisions = sort(randperm(numUsers-2, numGroups-1) + 1, 'ascend')
divisions = [0, divisions, numUsers]
% Create cell array with random number of users in each groups
groups = cell(1, numGroups);
for k = 1 : numGroups
indexes = divisions(k)+1:divisions(k+1);
% Assign users to the kth group:
usersInThisGroups = length(indexes);
fprintf('Assigning %d users (indexes %d to %d) to group %d.\n', ...
usersInThisGroups, divisions(k)+1,divisions(k+1), k);
groups{k} = s(indexes);
end
celldisp(groups); % Display groups in command window.
1 Comment
Duplicate:
@Prabha Kumaresan: please stop spamming the same question repeatedly. It does not get you help faster, but in fact makes it harder for us to help you.
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!