MATLAB: Conversion of binary to decimal

conversion of binary to decimal passing through a variable

binary=1011 decimal=bin2dec('binary')
this code shows a error – Error using bin2dec Binary string may consist only of characters 0 and 1
Is there is method for conversion of binary to decimal through passing a variable which consists binary numbers?????

Best Answer

Hi ablaze, Your code has bin2dec trying to convert a string containing the word 'binary'. Try
a = '1011'
bin2dec(a)