Problem within the while loop

1 回表示 (過去 30 日間)
Aftab Ahmed Khan
Aftab Ahmed Khan 2014 年 6 月 12 日
コメント済み: Star Strider 2014 年 6 月 12 日
Hi everyone, This code is running but the problem which i have is in the statement enclosed in the ********. Every time the while loop executes it should remove the first value from the arrival variable but it is not doing what it should do, like removing the first value one by one during each loop iteration.
tmax = 30;
nowtime = 0;
A = 2;
D = 2;
while nowtime < tmax
nowtime = min(arrivals);
available_channels = find((BS_channeltable)==0);
first_available = min(available_channels);
BS_channeltable(first_available) = 1; % Allocating the channel to busy status (1)
fprintf(fid,'\n One channel is allocated.');
* * * * * *arrivals = arrivals(A:end);* * * * * *
A = A+1;
if nowtime >= min(departures);
occupied_channels = find((BS_channeltable)==1);
first_release = min(occupied_channels);
BS_channeltable(first_release) = 0; % Allocating the channel to idle status (0)
fprintf(fid,'\n One channel is released.');
departures = departures(D:end);
D = D+1;
elseif nowtime > max(departures)
fprintf(fid,'\nNo more events to arrrive or depart, simulation stops.');
return;
end
end
  2 件のコメント
David Sanchez
David Sanchez 2014 年 6 月 12 日
Is arrivals a (1 x XXXXX) or (XXXXXX x 1) array?
Aftab Ahmed Khan
Aftab Ahmed Khan 2014 年 6 月 12 日
its a (XXXXXX x 1) array.

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

採用された回答

Star Strider
Star Strider 2014 年 6 月 12 日
Is this what you want to do?
Example:
arrivals = 1:10;
A = 1;
for k1 = 1:5
arrivals = arrivals(A:end)
A = 2;
end
  2 件のコメント
Aftab Ahmed Khan
Aftab Ahmed Khan 2014 年 6 月 12 日
Yuppppp, done. Cheers bro.
Star Strider
Star Strider 2014 年 6 月 12 日
My pleasure!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by