bin2dec

Converts a string, matrix or cell array, s, representing binary number(s) to decimal equivalent(s).

Syntax

R = bin2dec(s)

Inputs

s
String, matrix or cell array representing binary number(s). Spaces are ignored.
Type: string | mat | cell

Outputs

R
If s is a matrix or cell array, R, will be a column matrix with one row for each element. Any conversions which are invalid will result in 'Nan'
Type: integer | mat

Examples

String to integer example:
R = bin2dec('1100001')
R = 97
Matrix of strings with spaces example:
R = bin2dec(['0110 0001'; '0100 0001'; '0000 0001'])
R =
97
65
 1