mvl2dec

Convert multivalued logic to decimal

Description

example

D = mvl2dec(mv_logic_char) converts a multivalued logic to a positive decimal integer.

Note

If mv_logic_char contains any character other than '0' or '1', the output returned is NaN.

example

D = mvl2dec(mv_logic_char,signed) converts a signed multivalued logic to a positive or negative decimal integer.

Examples

collapse all

Find the decimal integer equivalent for multivalued logic vector.

mvl2dec('010111')
ans = 23

Find the decimal integer equivalent for multivalued logic vector with one or more values other than 0 and 1. The function returns NaN.

mvl2dec('x01201')
ans = NaN

Find the decimal integer equivalent for signed multivalued logic vector. The second input argument indicates that the input is a signed vector.

mvl2dec('10111',true)
ans = -9

Input Arguments

collapse all

Multivalued logic to convert, specified as a character vector or string scalar.

Data Types: char | string

Implementation of the multivalued logic, specified as one of the values in this table

Value

Description

true

The input is a signed multivalued logic. The function assumes that the first character mv_logic_char(1) is a signed bit of a 2's complement number.

false

The input is an unsigned multivalued logic.

Data Types: logical

See Also

Introduced in R2008a