If , else if statement problem
5 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
per isakson
on 18 Feb 2015
Edited: per isakson
on 18 Feb 2015
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 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!