Boolen logic operations between integer numbers

5 ビュー (過去 30 日間)
Josh Shamir
Josh Shamir 2016 年 11 月 22 日
コメント済み: Josh Shamir 2016 年 11 月 22 日
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

採用された回答

Alexandra Harkai
Alexandra Harkai 2016 年 11 月 22 日
編集済み: Alexandra Harkai 2016 年 11 月 22 日
>> logical(3)
ans =
1
>> logical(-4)
ans =
1
So 1 && 1 = 1, according to the numeric-to-logical documentation.
  2 件のコメント
Guillaume
Guillaume 2016 年 11 月 22 日
To add to this, only 0 is considered false by matlab (and many many other languages)
Josh Shamir
Josh Shamir 2016 年 11 月 22 日
Thank you Alexandra Harkai and Guillaume for the valuable help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by