We have moved to @ Placement Papers Hub !! Visit our new website here for more..

Logical Operations Matlab Matrix


Matlab Matrix Logical Operations

A & B A| B ~A
The symbols &, |, and ~ are the logical array operators AND, OR, and NOT. These operators are commonly used in conditional statements, such as if and while, to determine whether or not to execute a particular block of code. Logical operations return a logical array with elements set to 1 (true) or 0 (false), as appropriate.
xor(A,B) represents the logical exclusive disjunction. xor(A,B) is true when either A or B are true. If both A and B are true or false, xor(A,B) is false.


>> A=[1 1 0; 1 1 1; 0 0 1]

A =

     1     1     0
     1     1     1
     0     0     1

>> B=[1 0 0; 0 0 0; 1 1 1]

B =

     1     0     0
     0     0     0
     1     1     1

*A and B we can write like this below

>> A&B

ans =

     1     0     0
     0     0     0
     0     0     1
*A or B we can write like this below
>> A|B

ans =

     1     1     0
     1     1     1
     1     1     1

* Not A we can write like this below
>> ~A

ans =

     0     0     1
     0     0     0
     1     1     0