Documentation

### This is machine translation

Mouseover text to see original. Click the button below to return to the English version of the page.

# Logical Operations

True or false (Boolean) conditions

The `logical` data type represents `true` or `false` 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 a Condition.

## Functions

 `Logical Operators: Short-circuit` Logical operations with short-circuiting `and` Find logical AND `not` Find logical NOT `or` Find logical OR `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

Find Array Elements That Meet a Condition

This example shows how to filter the elements of an array by applying conditions to the array.

Reduce Logical Arrays to Single Value

This example shows how to use the `any` and `all` functions to reduce an entire array to a single logical value.

Operator Precedence

Precedence rules determine the order in which MATLAB evaluates an expression.

Truth Table for Logical Operations

This reference table shows the results of applying the binary logical operators to a series of logical `1` (`true`) and logical `0` (`false`) scalar pairs.

Determine if Arrays Are Logical

Determine whether an array is logical by testing the entire array or each element individually.