Cody

# Problem 6. Select every other element of a vector

Solution 2065737

Submitted on 21 Dec 2019 by Jude Alnas
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))

i = 1 3 5 7 9 y = 0.5168 0.5232 0.1046 0.7997 0.4618

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

i = Columns 1 through 30 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 33 35 37 39 41 43 45 47 49 51 53 55 57 59 Columns 31 through 50 61 63 65 67 69 71 73 75 77 79 81 83 85 87 89 91 93 95 97 99 y = Columns 1 through 18 0.0628 0.6306 0.3658 0.7361 0.1712 0.9275 0.8201 0.2996 0.5673 0.8244 0.9287 0.7965 0.7432 0.6238 0.6815 0.0712 0.7369 0.1282 Columns 19 through 36 0.9666 0.9943 0.6653 0.6524 0.6679 0.9013 0.0618 0.9021 0.0276 0.9864 0.0897 0.1471 0.7564 0.1147 0.5361 0.1771 0.8514 0.4925 Columns 37 through 50 0.1392 0.3082 0.0708 0.1497 0.5458 0.6691 0.7187 0.2737 0.5251 0.2910 0.7469 0.0841 0.1602 0.7678

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))

i = 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31 y = 'Aogiegiaaayafrwy'