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 CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by