Cody

# Problem 6. Select every other element of a vector

Solution 132709

Submitted on 30 Aug 2012 by Frosch
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 = Columns 1 through 4 0.15 0.47 0.26 0.34 Column 5 0.99

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

y = Columns 1 through 4 0.35 0.61 0.90 0.77 Columns 5 through 8 0.30 0.47 0.14 0.06 Columns 9 through 12 0.32 0.72 0.34 0.24 Columns 13 through 16 0.57 0.12 0.72 0.74 Columns 17 through 20 0.30 0.71 0.49 0.87 Columns 21 through 24 0.91 0.70 0.76 0.32 Columns 25 through 28 0.56 0.21 0.94 0.11 Columns 29 through 32 0.32 0.25 0.01 0.07 Columns 33 through 36 0.49 0.75 0.56 0.53 Columns 37 through 40 0.75 0.71 0.10 0.16 Columns 41 through 44 0.85 0.25 0.70 0.27 Columns 45 through 48 0.27 0.62 0.83 0.88 Columns 49 through 50 0.64 0.32

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 = Aogiegiaaayafrwy