random grouping of users and subcarriers

1 Ansicht (letzte 30 Tage)
Prabha Kumaresan
Prabha Kumaresan am 19 Dez. 2017
Kommentiert: Prabha Kumaresan am 19 Dez. 2017
Please anyone help me to execute the following code. clear all; clc;
N_UE=[2 4 6 8 10]; N_SC=[20 30 40 50 60];
t= 1:length(N_UE) r = 1:length(N_SC)
s= randperm(length(N_UE)) p= randperm(length(N_SC))
G = rand(s,p)
  4 Kommentare
Birdman
Birdman am 19 Dez. 2017
You want to randomly pick from N_UE or N_SC?
Prabha Kumaresan
Prabha Kumaresan am 19 Dez. 2017
yes

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Birdman
Birdman am 19 Dez. 2017
Change this line
G = rand(s,p)
to this
G=[randsample(N_SC(r),1) randsample(N_UE(p),1)]
  1 Kommentar
Prabha Kumaresan
Prabha Kumaresan am 19 Dez. 2017
It worked thanks a lot.Now if I want to group users randomly there by sharing the subcarriers among the group
how the following command can be modified
numGroups = 5; % Need to divide G up into 5 groups
divisions = sort(randperm(numUsers, numGroups) , '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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by