Cody

Problem 43980. Find the binary code

Solution 1094398

Submitted on 29 Dec 2016 by Adi Zabidi
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   Pass
numBit = 2; analogValue =1; binary=binaryCode(numBit,analogValue); binary_correct= '01'; assert(isequal(binary,binary_correct))

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

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

Suggested Problems

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!