Clear Filters
Clear Filters

Boolen logic operations between integer numbers

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

Accepted Answer

Alexandra Harkai
Alexandra Harkai on 22 Nov 2016
Edited: Alexandra Harkai on 22 Nov 2016
>> logical(3)
ans =
>> logical(-4)
ans =
So 1 && 1 = 1, according to the numeric-to-logical documentation.
Guillaume on 22 Nov 2016
To add to this, only 0 is considered false by matlab (and many many other languages)
Josh Shamir
Josh Shamir on 22 Nov 2016
Thank you Alexandra Harkai and Guillaume for the valuable help.

Sign in to comment.

More Answers (0)


Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!