Documentation

mvl2dec

Convert multivalued logic to decimal

Syntax

mvl2dec('mv_logic_string')
mvl2dec('mv_logic_string', signed)

Description

mvl2dec('mv_logic_string') converts a multivalued logic string to a positive decimal. If mv_logic_string contains any character other than '0' or '1', NaN is returned. mv_logic_string must be a vector.

mvl2dec('mv_logic_string', signed) converts a multivalued logic string to a positive or a negative decimal. If signed is true, this function assumes the first character mv_logic_string(1) to be a signed bit of a 2s complement number. If signed is missing or false, the multivalued logic string becomes a positive decimal.

Examples

The following function call returns the decimal value 23:

>>mvl2dec('010111')

The following function call returns NaN:

>>mvl2dec('xxxxxx')

The following function call returns the decimal value -9:

>>mvl2dec('10111',true)

See Also

Was this topic helpful?