You can convert the array to a decimal number by first converting it into a binary string, then using the BIN2DEC function to convert the string into a number:
x = [1 0 0 0 0 0 0 0];
str_x = num2str(x);
str_x(isspace(str_x)) = '';
y = bin2dec(str_x);
For MATLAB 7.0 (R14) and releases after that, BIN2DEC ignores any space (' ')
characters in the input string. Hence, the following step is not required in the above code:
str_x(isspace(str_x)) = '';
Please note that the BIN2DEC function works with strings of size less than 52 bits.
To convert a binary string with more than 52 bits, you would need to use the symbolic Math Toolbox in MATLAB.
For example, a binary string can be converted using the text2int function in MATLAB 7.8 (R2009a).
z = evalin(symengine,'text2int("1111000101111100010111110001011111000001011111000101010",2)')
Best Answer