what does the "-1" means in conditional statement?

조회 수: 3 (최근 30일)
Imtiaz nabi
Imtiaz nabi 2022년 1월 25일
편집: Stephen23 2022년 1월 25일
Hi I am trying to understand a code which has some "if" statemets.
Now normally we pass true or false to the if else statement right? but in this case the state has a -1 what does this -1 means?
here is the line of code that I am trying to understand
for i=1:CT.MaxSatNum
clear tempsat;
if (SimGlobal.aSatData(i).sOrbitData.sEphData.PRN~=-1)

채택된 답변

DGM
DGM 2022년 1월 25일
Entering the if structure isn't conditional on -1, it's conditional on whether SimGlobal.aSatData(i).sOrbitData.sEphData.PRN is not equal to -1. The output of that test is a logical value.
A = 2;
if (A ~= -1)
disp('tested true')
end
tested true
A ~= -1 % this returns a logical scalar
ans = logical
1
  댓글 수: 4
Imtiaz nabi
Imtiaz nabi 2022년 1월 25일
So I shouldn't worry about any rocket science here... there are only two statements true or false 1 and 0 right?
Stephen23
Stephen23 2022년 1월 25일
편집: Stephen23 2022년 1월 25일
"there are only two statements true or false 1 and 0 right?"
MATLAB's logical class only has two values: true and false:
They are respectively equivalent to and often displayed as 1 and 0.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by