Cody

# Problem 6. Select every other element of a vector

Solution 800353

Submitted on 3 Jan 2016 by sakz
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 -1 1 -1 1 -1 1 -1 1 -1

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

a = Columns 1 through 16 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 17 through 32 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 33 through 48 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 49 through 64 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 65 through 80 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 81 through 96 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 97 through 100 1 -1 1 -1

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 = Columns 1 through 16 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 Columns 17 through 31 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1