Logical -1 = Logical 1?

Dear all, While reviewing a code I found the following expression:
assert(fid ~= -1, etc
By checking the logical operators I found that for a true condition the number is 1.
I would like to ask if in Matlab applies the same rule than for other packages where any non-zero value is true.
Thanks,
Diego

 채택된 답변

Matt Fig
Matt Fig 2012년 11월 13일
편집: Matt Fig 2012년 11월 13일

0 개 추천

Yes:
logical([-1 0 1 20 -10 .001 eps ])
The exception is NaN. NaN is non-zero, yet cannot be converted to logical. Try to do it and see what you get!

댓글 수: 2

Diego
Diego 2012년 11월 13일
Thank you Matt.
Regards,
Diego
Daniel Shub
Daniel Shub 2012년 11월 14일
I think i is also an exception in that it is neither true nor false.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

질문:

2012년 11월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by