Boolen logic operations between integer numbers

Dear All,
I would like to know the reasons why this happens:
>> 3 && -4
ans =
1
Thanks in advance for your kindly support.
Best Regards,
Josh

 采纳的回答

>> logical(3)
ans =
1
>> logical(-4)
ans =
1
So 1 && 1 = 1, according to the numeric-to-logical documentation.

2 个评论

To add to this, only 0 is considered false by matlab (and many many other languages)
Thank you Alexandra Harkai and Guillaume for the valuable help.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Simulation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by