Cody

# Problem 6. Select every other element of a vector

Solution 1906515

Submitted on 20 Aug 2019 by Zhichen Zhu
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))

t = 10 i = 1 3 5 7 9 y = 0.7402 0.5140 0.8207 0.7976 0.4999

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

t = 100 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.6861 0.8978 0.9734 0.5126 0.5861 0.6435 0.4053 0.0401 0.3406 0.3912 0.1214 0.7734 0.7796 0.4220 0.5678 0.0873 0.6238 0.8620 Columns 19 through 36 0.2307 0.6268 0.4753 0.2061 0.4623 0.5071 0.4525 0.8736 0.7869 0.9011 0.0279 0.9679 0.7975 0.8581 0.9808 0.4748 0.1298 0.1339 Columns 37 through 50 0.0015 0.8860 0.4894 0.1384 0.4591 0.8198 0.7856 0.6152 0.5531 0.2560 0.3261 0.1981 0.4244 0.6454

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

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