LOGICAL Convert to Logical
Section: Type Conversion Functions
Usage
Converts the argument to a logical array. The syntax for its use isy = logical(x)
where x
is an n
-dimensional numerical array. Any nonzero
element maps to a logical 1.
Example
Here we convert an integer array tological
:
--> logical([1,2,3,0,0,0,5,2,2]) ans = 1 1 1 0 0 0 1 1 1
The same example with double precision values:
--> logical([pi,pi,0,e,0,-1]) ans = 1 1 0 1 0 1