boolean - Convert numeric value to Boolean value - MATLAB (original) (raw)

Main Content

Convert numeric value to Boolean value

Syntax

Description

`tf` = boolean(`X`) converts the numeric expression X into a Boolean value. If the expression evaluates to zero, boolean returns logical 0 (false). Otherwise, boolean returns logical1 (true).

example

Note

The operator boolean is supported in Stateflow® charts. In MATLAB®, use logical.

Examples

expand all

Cast the expression x+3 as a Boolean value and assign the value to the data y.

Stateflow chart that uses the boolean operator.

Input Arguments

expand all

Numeric expression, specified as a scalar, vector, matrix, or multidimensional array.

Example: boolean(x+3)

Version History

Introduced before R2006a