%% Convert Text Representing Binary Value
% Convert a character vector that represents a binary value to a decimal number.

binStr = '10111';
D = bin2dec(binStr)

%
% Starting in R2019b, you can write values in binary format directly without using bin2dec. Use the 0b prefix and do not use quotation marks. MATLAB® stores the value as an integer, not as text.

D = 0b10111

% Copyright 2019 The MathWorks, Inc.