or
Logical OR, the function form of the operator |.
Category: Symbolic Computations in MATLAB > Operators and Elementary Operations
Syntax
C = or(A, B)
Same as A | B.
Description
The result is true at positions where at least one operand is nonzero. Operands may be numbers or logicals and are combined with the usual rules for compatible sizes.
For scalar conditions in if and while, || short-circuits and is generally preferred; or and | always evaluate both operands.
Input arguments
A, B- Numeric or logical arrays with compatible sizes. Nonzero means true.
Output arguments
C- Logical array: true where at least one input is nonzero.
Example
Elementwise OR
or([1 0 0], [0 0 1])
x = [-5 1 7 12];
x(or(x < 0, x > 10))
Output
ans = 1×3 logical array
1 0 1
ans = 1×2
-5 12
Notes
Symbolic operands are not supported (or(x > 1, x < 0) raises an error).