Logical (Boolean) Operations - MATLAB & Simulink (original) (raw)

Main Content

True or false conditions

MATLABĀ® represents Boolean data using the logical data type. This data type represents true andfalse states using the numbers 1 and 0, respectively. Certain MATLAB functions and operators return logical values to indicate fulfillment of a condition. You can use those logical values to index into an array or execute conditional code. For more information, see how to Find Array Elements That Meet Conditions.

Functions

& Find logical AND
Short-Circuit && Logical AND with short-circuiting
~ Find logical NOT
| Find logical OR
[Short-Circuit | ](ref/shortcircuitor.html)
xor Find logical exclusive-OR
all Determine if all array elements are nonzero or true
any Determine if any array elements are nonzero
false Logical 0 (false)
find Find indices and values of nonzero elements
islogical Determine if input is logical array
logical Convert numeric values to logicals
true Logical 1 (true)

Topics