unreachable and dead code

조회 수: 54 (최근 30일)
VINAY
VINAY 2026년 2월 24일 4:25
댓글: VINAY 대략 12시간 전
why i am getting unreachable and dead code warning , i am not able to understant.
if anyone knows, please help me.
  댓글 수: 2
Image Analyst
Image Analyst 대략 17시간 전
I can't even read that thing. What is that diagram? Is it Stateflow or Simulink (which I don't have)? How did you run your check on it? You might have some condition that is always false, like
value = false
if value
% Do something if value = true
% This block will never get executed since value is not a variable,
% it's a constant.
end
VINAY
VINAY 대략 8시간 전
Now you can check

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

답변 (1개)

Fangjun Jiang
Fangjun Jiang 대략 3시간 전
Before the Simulink funciton Counter_Check1() is called, there is this operation "Cnt=Cnt+CntTime1". Then, inside the function, there is this comparison "Cnt>=CntTime1". Maybe due to the fact that the value of "Cnt=InitValue" is zero or positive, the comparison "Cnt>=CntTime1" is always true.
So the "{%Do Nothing}" transition is never reached. It might be okay in terms of the logic, but in terms of software, it is regarded as "unreachable" or "dead code". It is not a good practice to have unreachable or dead code.
Change the "InitValue" to be negative to see if the warning disappear.
  댓글 수: 1
VINAY
VINAY 대략 2시간 전
hi @Fangjun Jiang i changed the "InitValue" To -ve eventhough warning is not dissppeared.

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

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by