logical

Converts x to a logical type.

Syntax

logical(x)

Inputs

x
A numeric value.
Type: double | integer | char | string | logical | struct | cell
Dimension: scalar | vector | matrix

Outputs

R
Either true (1) or false (0). The numeric value 0 goes to false, while every other numeric value goes to true.

Examples

Logical example:
logical(10)
ans = 1
Logical example:
logical(0)
ans = 0
Logical example:
logical(NaN)
Error: cannot convert NaN to logical