MathLab

1.Write a function with the header [d] = myBin2Dec(b) where b is a binary number represented by a one-dimensional array of ones and zeros. The last element of b represents the coefficient of 20, the second to last element of b represents the coefficient of 21,and so on. The output variable, d, should be the decimal representation of b.

  1. Write a function with the header [b] = myDec2Bin(d), where d is a positive integer in decimal (base 10), and b is the binary representation of d. The output b must be a row vector of ones and zeros, and the leading term must be a 1 unless the decimal input value is 0.

Sample Solution