Logical -1 = Logical 1?

1 次查看(过去 30 天)
Diego
Diego 2012-11-13
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
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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by