필터 지우기
필터 지우기

If , else if statement problem

조회 수: 5 (최근 30일)
Cladio Andrea
Cladio Andrea 2015년 2월 18일
편집: per isakson 2015년 2월 18일
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

채택된 답변

per isakson
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개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by