can anyone help me to solve the error

1 回表示 (過去 30 日間)
Prabha Kumaresan
Prabha Kumaresan 2017 年 12 月 26 日
コメント済み: Prabha Kumaresan 2017 年 12 月 27 日
clear all;
clc;
N_UE=[2 4 6 8 10];
N_SC=[12 14 16 18 20];
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([2 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}];
end
end
If i run the code i am getting Error using randsample (line 131) K must be less than or equal 2 for sampling without replacement.
Error in test (line 35) idx=randsample(1:size(C_copy,1),e);
Please help me to solve this issue.
  2 件のコメント
Image Analyst
Image Analyst 2017 年 12 月 26 日
Prabha Kumaresan
Prabha Kumaresan 2017 年 12 月 27 日
No K in my code but when i run the code it displays the error in the way.I have also attached the image of it.

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

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 12 月 26 日
You ended up with a value of e that was 3 or more when you only had two rows in C_copy

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by