can anybody help me to execute the following code

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 comentario

Stephen23
Stephen23 el 22 de Dic. de 2017
Editada: Stephen23 el 22 de Dic. de 2017
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.

Respuestas (0)

La pregunta está cerrada.

Etiquetas

Preguntada:

el 22 de Dic. de 2017

Editada:

el 22 de Dic. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by