This is machine translation

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

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Convert multivalued logic to decimal


mvl2dec('mv_logic_char', signed)


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.


collapse all

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

ans = 23

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

ans = NaN

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

ans = -9

See Also

Introduced in R2008a