how to implement two different scenarios in the same code.

조회 수: 3 (최근 30일)
Prabha Kumaresan
Prabha Kumaresan 2018년 4월 5일
댓글: Prabha Kumaresan 2018년 4월 5일
scenario 1:
N_rng=[1 2 23]
for s=1:length(N_rng)
this_seed = N_rng(s);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows=1:N_UE(t);
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
end
scenario 2:
N_rng=[1 2 5 6 9 11 12 19 47 74 84 91 153];
for s=1:length(N_rng)
this_seed = N_rng(s);
fprintf('Below results are for rng = %d\n', this_seed);
rng(this_seed);
unused_rows=1:N_UE(t);
while ~isempty(unused_rows)
N_UE_rows=ceil(sqrt(randi([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
end
Could anyone tell me how to implement two different scenario in the same code
  댓글 수: 2
Greg
Greg 2018년 4월 5일
Not sure what you're asking. What's wrong with exactly what you posted?
Are you trying to ask how to use if logic to choose between the 2 scenarios?
Prabha Kumaresan
Prabha Kumaresan 2018년 4월 5일
The difference between scenario 1 and scenario 2 are
scenario 1 uses the command
N_rng=[1 2 23]; N_UE_rows=2;
and scenario 2 uses
N_rng=[1 2 5 6 9 11 12 19 47 74 84 91 153];
N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
the rest of the command remains the same for both scenario.
I want actually to run the both scenarios using the
same code,under the condition for scenario 1 uses N_rng=[1 2 23];
N_UE_rows=2; and scenario 2 uses
N_rng=[1 2 5 6 9 11 12 19 47 74 84 91 153];
N_UE_rows=ceil(sqrt(randi([numel(unused_rows)])));
could you help me to solve it.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by