Cody

# Problem 6. Select every other element of a vector

Solution 1926080

Submitted on 8 Sep 2019 by Aleksandr Montelli
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.6273 0.3623 0.5082 0.3166 0.3931

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.9381 0.1566 0.6293 0.4164 0.3981 0.9040 0.7663 0.2817 0.7976 0.1922 0.2396 0.4940 0.5127 0.4730 0.3877 0.9354 0.5841 0.7690 Columns 19 through 36 0.4179 0.0091 0.3799 0.2513 0.9381 0.0236 0.4094 0.9642 0.1994 0.5350 0.4114 0.6445 0.6407 0.5726 0.2972 0.7361 0.2219 0.6148 Columns 37 through 50 0.0162 0.3967 0.8426 0.3037 0.9049 0.4075 0.6566 0.8987 0.1406 0.4081 0.5901 0.3558 0.5731 0.7960

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'