Cody

# Problem 43602. Convert array of decimal numbers into binary numbers array.

Solution 1574303

Submitted on 3 Jul 2018
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
x = 1; y_correct = 1; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 49

Assertion failed.

2   Fail
x = 1:8; y_correct = [1 10 11 100 101 110 111 1000]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 48 48 48 49 48 48 49 48 48 48 49 49 48 49 48 48 48 49 48 49 48 49 49 48 48 49 49 49 49 48 48 48

Error using assert The condition input argument must be a scalar logical. Error in Test2 (line 3) assert(sum(abs(Converter(x)-y_correct))<1e-3)

3   Fail
x = 8:20; y_correct = [1000 1001 1010 1011 1100 1101 1110 1111 10000 10001 10010 10011 10100]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 48 49 48 48 48 48 49 48 48 49 48 49 48 49 48 48 49 48 49 49 48 49 49 48 48 48 49 49 48 49 48 49 49 49 48 48 49 49 49 49 49 48 48 48 48 49 48 48 48 49 49 48 48 49 48 49 48 48 49 49 49 48 49 48 48

Error using assert The condition input argument must be a scalar logical. Error in Test3 (line 3) assert(sum(abs(Converter(x)-y_correct))<1e-3)

4   Fail
x = 1:2:21; y_correct = [1 11 101 111 1001 1011 1101 1111 10001 10011 10101]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 48 48 48 48 49 48 48 48 49 49 48 48 49 48 49 48 48 49 49 49 48 49 48 48 49 48 49 48 49 49 48 49 49 48 49 48 49 49 49 49 49 48 48 48 49 49 48 48 49 49 49 48 49 48 49

Error using assert The condition input argument must be a scalar logical. Error in Test4 (line 3) assert(sum(abs(Converter(x)-y_correct))<1e-3)

5   Fail
x = 2.^(0:10); y_correct = [1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 48 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 48 48

Error using assert The condition input argument must be a scalar logical. Error in Test5 (line 3) assert(sum(abs(Converter(x)-y_correct))<1e-3)

6   Fail
x = 2.^(1:10) - 1; y_correct = [1 11 111 1111 11111 111111 1111111 11111111 111111111 1111111111]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 48 48 48 48 48 48 48 48 48 49 48 48 48 48 48 48 48 48 49 49 48 48 48 48 48 48 48 49 49 49 48 48 48 48 48 48 49 49 49 49 48 48 48 48 48 49 49 49 49 49 48 48 48 48 49 49 49 49 49 49 48 48 48 49 49 49 49 49 49 49 48 48 49 49 49 49 49 49 49 49 48 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49 49

Error using assert The condition input argument must be a scalar logical. Error in Test6 (line 3) assert(sum(abs(Converter(x)-y_correct))<1e-3)

7   Fail
x = 2:2:20; y_correct = [10 100 110 1000 1010 1100 1110 10000 10010 10100]'; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 48 48 48 49 48 48 48 49 48 48 48 48 49 49 48 48 49 48 48 48 48 49 48 49 48 48 49 49 48 48 48 49 49 49 48 49 48 48 48 48 49 48 48 49 48 49 48 49 48 48

Error using assert The condition input argument must be a scalar logical. Error in Test7 (line 3) assert(sum(abs(Converter(x)-y_correct))<1e-3)

8   Fail
x = 42; y_correct = 101010; assert(sum(abs(Converter(x)-y_correct))<1e-3)

y = 49 48 49 48 49 48

Assertion failed.