Cody

Problem 43980. Find the binary code

Solution 2131273

Submitted on 17 Feb 2020
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Fail
numBit = 2; analogValue =1; binary=binaryCode(numBit,analogValue); binary_correct= '01'; assert(isequal(binary,binary_correct))

ans = '10' ans = '10'

Undefined function 'filplr' for input arguments of type 'double'. Error in binaryCode (line 4) filplr(ans-'0')+'0' Error in Test1 (line 3) binary=binaryCode(numBit,analogValue);

2   Fail
numBit = 4; analogValue =15; binary=binaryCode(numBit,analogValue); binary_correct= '1111'; assert(isequal(binary,binary_correct))

ans = '11110' ans = '1111'

Undefined function 'filplr' for input arguments of type 'double'. Error in binaryCode (line 4) filplr(ans-'0')+'0' Error in Test2 (line 3) binary=binaryCode(numBit,analogValue);

3   Fail
numBit = 6; analogValue =63; binary=binaryCode(numBit,analogValue); binary_correct= '111111'; assert(isequal(binary,binary_correct))

ans = '1111110' ans = '111111'

Undefined function 'filplr' for input arguments of type 'double'. Error in binaryCode (line 4) filplr(ans-'0')+'0' Error in Test3 (line 3) binary=binaryCode(numBit,analogValue);

Suggested Problems