Determine if Arrays Are Logical
To determine whether an array is logical, you can test the entire array or each element
individually. This is useful when you want to confirm the output data type of a function.This page shows several ways to determine if an array is logical.In this section...
“Identify Logical Matrix” on page 5-7
“Test an Entire Array” on page 5-8
“Test Each Array Element” on page 5-8
“Summary Table” on page 5-9Identify Logical Matrix
Create a 3-by-6 matrix and locate all elements greater than 0.5.A = gallery('uniformdata',[3,6],0) > 0.5A =1 0 0 0 1 0
0 1 0 1 1 1
1 1 1 1 0 1The result, A, is a 3-by-6 logical matrix.Use the whos function to confirm the size, byte count, and class (or data type) of the
matrix, A.whos AName Size Bytes Class AttributesA 3x6 18 logicalThe result confirms that A is a 3-by-6 logical matrix.Determine if Arrays Are Logical