logo for matrixlab-examples.com
leftimage for matrixlab-examples.com

Logical NOT


In MATLAB, ~A performs a logical NOT of input array A, and returns an array containing elements set to either logical 1 (TRUE) or logical 0 (FALSE). This is the truth table and the representation of a NOT Gate as it's represented in digital electronics.


A    ~A
0      1
1      0
not gate - example in Matlab
This is a logical NOT gate, as represented in electronic circuits


An element of the output array is set to 1 if A contains a zero value element at that same array location.  Otherwise, that element is set to 0.



Example 1:
If matrix A is:
A =

     0     0     1     1
     1     1     0     0
     0     0     0     0
     1     1     1     1

Then, the NOT A is produced:

>> ~A

ans =

     1     1     0     0
     0     0     1     1
     1     1     1     1
     0     0     0     0



Example 2:
If vector x is:
x = 0     1     2    -3     0

Then, the NOT x is produced:

>> ~x

ans = 1     0     0     0     1


Boolean NOT and other operators



 From 'Logical NOT' to home

 From 'Logical NOT' to 'Boolean Algebra'
 
Top

Logical AND

Logical OR

XOR gate

De Morgan's Laws




footer for logical not page