Info

此问题已关闭。 请重新打开它进行编辑或回答。

can anybody help me to execute the following code

1 次查看(过去 30 天)
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 个评论
Stephen23
Stephen23 2017-12-22
编辑:Stephen23 2017-12-22
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.

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by