Cody

# Problem 1466. Convert Two Character String into a Binary Vector

Solution 2251144

Submitted on 2 May 2020 by Joshua Sonn
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
expect_bin=randi(2,1,10)-1; str=char(9*expect_bin+79); binvec=str2Binvec(str); assert(isequal(expect_bin,binvec))

binvec = 1×10 uint16 row vector 79 79 88 79 79 88 88 88 79 88 binvec = 1×10 uint16 row vector 0 79 88 79 79 88 88 88 79 88 binvec = 1×10 uint16 row vector 0 0 88 79 79 88 88 88 79 88 binvec = 1×10 uint16 row vector 0 0 1 79 79 88 88 88 79 88 binvec = 1×10 uint16 row vector 0 0 1 0 79 88 88 88 79 88 binvec = 1×10 uint16 row vector 0 0 1 0 0 88 88 88 79 88 binvec = 1×10 uint16 row vector 0 0 1 0 0 1 88 88 79 88 binvec = 1×10 uint16 row vector 0 0 1 0 0 1 1 88 79 88 binvec = 1×10 uint16 row vector 0 0 1 0 0 1 1 1 79 88 binvec = 1×10 uint16 row vector 0 0 1 0 0 1 1 1 0 88 binvec = 1×10 uint16 row vector 0 0 1 0 0 1 1 1 0 1

2   Pass
expect_bin=randi(2,1,5)-1; str=char(9*expect_bin+79); binvec=str2Binvec(str); assert(isequal(expect_bin,binvec))

binvec = 1×5 uint16 row vector 79 88 79 79 79 binvec = 1×5 uint16 row vector 0 88 79 79 79 binvec = 1×5 uint16 row vector 0 1 79 79 79 binvec = 1×5 uint16 row vector 0 1 0 79 79 binvec = 1×5 uint16 row vector 0 1 0 0 79 binvec = 1×5 uint16 row vector 0 1 0 0 0

3   Pass
expect_bin=randi(2,1,25)-1; str=char(9*expect_bin+79); binvec=str2Binvec(str); assert(isequal(expect_bin,binvec))

binvec = 1×25 uint16 row vector 88 88 88 88 88 88 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 88 88 88 88 88 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 88 88 88 88 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 88 88 88 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 88 88 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 88 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 88 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 88 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 79 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 88 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 88 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 88 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 88 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 79 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 79 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 88 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 79 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 79 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 88 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 88 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 88 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 79 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 79 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 79 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 0 79 binvec = 1×25 uint16 row vector 1 1 1 1 1 1 1 1 0 1 1 1 1 0 0 1 0 0 1 1 1 0 0 0 0

### Community Treasure Hunt

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

Start Hunting!