Cody

# Problem 6. Select every other element of a vector

Solution 1880353

Submitted on 21 Jul 2019 by Ming Charles
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
x = rand(1,10); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = 0.3328 0.3658 0.9537 0.6533 0.9268

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = Columns 1 through 18 0.7972 0.7311 0.6373 0.1686 0.8927 0.0694 0.1334 0.3632 0.7763 0.7956 0.0812 0.9882 0.9159 0.9698 0.1895 0.0758 0.0336 0.6563 Columns 19 through 36 0.0472 0.8345 0.8357 0.4520 0.4569 0.8194 0.9949 0.7256 0.8228 0.0774 0.6861 0.6506 0.5678 0.7478 0.2614 0.0212 0.2681 0.0669 Columns 37 through 50 0.1550 0.1712 0.2421 0.9455 0.2191 0.2534 0.9413 0.5246 0.5093 0.6030 0.4748 0.2849 0.0794 0.9513

3   Pass
x = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away']; actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = 65 111 103 105 101 103 105 97 97 97 121 97 102 114 119 121