Cody

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

Solution 237153

Submitted on 28 Apr 2013 by Marco Castelli
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 = 0 0 0 0 0 0 0 0 0 0 ans = 1 4 5 6 10 binvec = 1 0 0 1 1 1 0 0 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 = 0 0 0 0 0 ans = 4 binvec = 0 0 0 1 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 = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Columns 17 through 25 0 0 0 0 0 0 0 0 0 ans = 1 3 6 9 10 12 19 20 21 binvec = Columns 1 through 16 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0 0 Columns 17 through 25 0 0 1 1 1 0 0 0 0 ```