not
Logical NOT, the function form of the operator ~.
Category: Symbolic Computations in MATLAB > Operators and Elementary Operations
Syntax
B = not(A)
Same as ~A.
Description
Every element is replaced by its logical negation. Numbers that are not zero count as true, so not([1 0 2]) gives [0 1 0]. The result is always of class logical.
A typical use is to invert a mask: x(not(isnan(x))) selects the elements that are not NaN.
Input arguments
A- Numeric or logical array. Zero is false, anything else is true.
Output arguments
B- Logical array of the same size: true where
Ais zero.
Example
Invert logicals and masks
not(true)
not([1 0 2])
x = [3 NaN 5];
x(not(isnan(x)))
Output
ans = logical
0
ans = 1×3 logical array
0 1 0
ans = 1×2
3 5
Notes
Symbolic operands are not supported (not(x > 1) raises an error).