If , else if statement problem
6 ビュー (過去 30 日間)
古いコメントを表示
Hello i guys i have matlab code of traffic generation but in one case i did not understand the if statement, can anyone tell me what is going on in that part please? I mean what is ones inside parenthesis?
HEARTBEAT = 1;
if(1)
% P_INDEP = [1 0.8; ...
% 0 0.2];
% P_COORD = [0.1 0.8; ...
% 0.9 0.2];
P_INDEP = [1 1; ...
0 0];
P_COORD = [0 1; ...
1 0];
LAMBDA = [(HEARTBEAT/(SUPPT(2)-SUPPT(1))*DATAPKTINTS/NUMMACHINES); 1];
% mean arrival rate,, generated data per device in a given time interval.
PRIORITY = [0;1];
STARTSTATE=1;
% overwrite default values
ALRMDISTIME={'unif',mean(SUPPT)-100,mean(SUPPT)+100};
% alarm is uniformly issued btw 1700-1900 in time interval
elseif(1)
P_INDEP = [1 0.8 0.01; ...
0 0.2 0;
0 0 0.99];
P_COORD = [0.1 0.8 0; ...
0.9 0.2 0.05;
0 0 0.95];
LAMBDA = [(HEARTBEAT/(SUPPT(2)-SUPPT(1))*DATAPKTINTS/NUMMACHINES); 1; 0.001];
PRIORITY = [0;1;0];
STARTSTATE=3;
% overwrite default values
ALRMDISTROX={'unif',mean(SUPPX)-200,mean(SUPPX)+100};
ALRMDISTROY={'unif',mean(SUPPX)-200,mean(SUPPX)+100};
else
P_INDEP = [1 0 0.01 0.000001;
0 0 0 0;
0 0 0.99 0;
0 1 0 0.999999];
P_COORD = [0 0 0 0.000001;
1 0 0.05 0;
0 0 0.95 0;
0 1 0 0.999999];
LAMBDA = [(HEARTBEAT/(SUPPT(2)-SUPPT(1))*DATAPKTINTS/NUMMACHINES); 1; 0.01; 0];
PRIORITY = [0;1;0;0];
STARTSTATE=3;
end
0 件のコメント
採用された回答
per isakson
2015 年 2 月 18 日
編集済み: per isakson
2015 年 2 月 18 日
The if - elseif - else - end control construct makes little sense.
if expression, statements, end evaluates an expression, and executes a group of
statements when the expression is true. An expression is true when its result is
nonempty and contains only nonzero elements (logical or real numeric). Otherwise,
the expression is false.
The elseif and else blocks are optional. The statements execute only if previous
expressions in the if...end block are false. An if block can include multiple
elseif blocks.
The expression, (1), is always non-zero thus only the the group of statements after if will be executed.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Upgrading Hydraulic Models to Use Isothermal Liquid Blocks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!