필터 지우기
필터 지우기

could anyone help me to solve the following issue

조회 수: 1 (최근 30일)
Prabha Kumaresan
Prabha Kumaresan 2018년 3월 5일
댓글: Prabha Kumaresan 2018년 3월 5일
The foolowing code works fine
N_UE=10;
unused_rows=1:N_UE;
while ~isempty(unused_rows);
N_UE_rows=ceil(sqrt(randi([2,numel(unused_rows)])));
if (N_UE_rows+1)==numel(unused_rows);
N_UE_rows=numel(unused_rows);
end
rows=unused_rows(randsample(length(unused_rows),N_UE_rows));
[~,idx]=find(ismember(unused_rows,rows));
unused_rows(idx)=[];
end
But the code executes with the result such that for each run the number of rows keep on changing either to 2 or 3. could anyone tell me how to fix the number of rows for each run to be 2.

채택된 답변

Rik
Rik 2018년 3월 5일
N_UE=10;
unused_rows=1:N_UE;
while ~isempty(unused_rows);
N_UE_rows=2;
if (N_UE_rows+1)==numel(unused_rows);
N_UE_rows=numel(unused_rows);
end
rows=unused_rows(randsample(length(unused_rows),N_UE_rows));
[~,idx]=find(ismember(unused_rows,rows));
unused_rows(idx)=[];
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by