Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

mvl2dec

Convert multivalued logic to decimal

Syntax

mvl2dec('mv_logic_char')
mvl2dec('mv_logic_char', signed)

Description

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

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

Examples

collapse all

The mvl2dec function accepts strings of binary digits and returns decimal integer values.

mvl2dec('010111')
ans =

    23

The following function call returns NaN because the binary digits are not either 1s and 0s.

mvl2dec('xxxxxx')
ans =

   NaN

The second argument indicates that the string is a signed number.

mvl2dec('10111',true)
ans =

    -9

See Also

Introduced in R2008a

Was this topic helpful?