Cody

# Problem 6. Select every other element of a vector

Solution 2016930

Submitted on 13 Nov 2019 by Nicholas Begg
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))

a = 1 3 5 7 9 y = 0.1479 0.7836 0.7429 0.8344 0.7043

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

a = 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.6839 0.6909 0.6808 0.3927 0.3523 0.1493 0.0731 0.2776 0.1699 0.6936 0.7533 0.0134 0.9576 0.8775 0.0027 0.6893 0.2745 0.0143 Columns 19 through 36 0.4167 0.2138 0.4877 0.0216 0.0421 0.6709 0.3394 0.4190 0.9534 0.8915 0.7056 0.0981 0.6947 0.3051 0.7449 0.5361 0.7588 0.9598 Columns 37 through 50 0.5687 0.3224 0.0571 0.2516 0.1347 0.1278 0.1056 0.8917 0.2431 0.8210 0.1914 0.7070 0.9537 0.4583

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

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