How to solve the error

3 ビュー (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2017 年 12 月 20 日
コメント済み: ANKUR KUMAR 2017 年 12 月 20 日
Please help me to execute the following code
clear all;
clc;
N_UE = [2 4 6 8 10]; % number of users
N_SC = [20 30 40 50 60]; % number of subcarriers
for t = 1:length(N_UE)
for r = 1:length(N_SC)
G=rand(N_UE(t),N_SC(r))% random selection of users and subcarriers
% subcarrier allocation to users%
siz = size(G);
idx = sub2ind(siz, randi([1,N_UE(t)], 1, siz(2)),1:siz(2));
C = zeros(siz);
C(idx) = G(idx);
s = randperm(N_UE(t))
% s = randperm(length(N_UE))
numGroups = 5; % Need to divide s up into 5 groups
divisions = sort(randperm(C, numGroups) , 'ascend')
% divisions = sort(randperm(numUsers-2, numGroups-1) + 1, 'ascend')
divisions = [0, divisions, C]
% 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); % D
end
end
as i am getting Error using randperm Inputs must be nonnegative scalar integers.
Error in two (line 25) divisions = sort(randperm(C,numGroups) ,'ascend')
  1 件のコメント
ANKUR KUMAR
ANKUR KUMAR 2017 年 12 月 20 日
Is this your homework problem? Prog for the same homework question can be found here: https://in.mathworks.com/matlabcentral/answers/373858-could-anyone-tell-me-how-to-execute-the-following-code

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by