Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
Could anybody tell me the working of coding
조회 수: 1 (최근 30일)
이전 댓글 표시
clear all;
clc;
N_UE=[10 20 30 40 50];
N_SC=[60 70 80 90 100];
for t= 1:length(N_UE)
for r = 1:length(N_SC)
C=rand(N_UE(t),N_SC(r));
N_G=4;%No of group
B = cell(N_G,1);
sumB = cell(N_G,1);
C_copy = C;
for d=1:1:N_G
if d==N_G
sz=length(C_copy(:,1));
e=sz;
else
if d==1
e=randi([1 5]);% select No of UE randomly
else
sz=length(C_copy(:,1));
sz=ceil(sz/2);
e=randi([1 sz]);% select No of UE randomly
end
end
idx=randsample(1:size(C_copy,1),e);
B{d} = C_copy(idx,:);
C_copy(idx,:) = [];
[rows, columns] = size(B{d});
% Get sum of columns and replicate vertically.
sumB{d} = repmat(sum(B{d},1), [rows, 1]);
end
% E=[sumB{1}; sumB{2};sumB{3};sumB{4};sumB{5};sumB{6};sumB{7};sumB{8};sumB{9};sumB{10}];
E=[sumB{1}; sumB{2};sumB{3};sumB{4}];
end
end
댓글 수: 0
답변 (1개)
Walter Roberson
2017년 12월 29일
As I posted before, you need to put an upper bound on the number of items you randomly select, and the upper bound needs to be (number of remaining groups minus 1)
I guess I needed to be more explicit: in your code, the number of remaining groups is (N_G - d)
이 질문은 마감되었습니다.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!