Cody

# Problem 6. Select every other element of a vector

Solution 551202

Submitted on 31 Dec 2014 by Ron
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))

count = 1 count = 2 count = 3 count = 4 count = 5 count = 6

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

count = 1 count = 2 count = 3 count = 4 count = 5 count = 6 count = 7 count = 8 count = 9 count = 10 count = 11 count = 12 count = 13 count = 14 count = 15 count = 16 count = 17 count = 18 count = 19 count = 20 count = 21 count = 22 count = 23 count = 24 count = 25 count = 26 count = 27 count = 28 count = 29 count = 30 count = 31 count = 32 count = 33 count = 34 count = 35 count = 36 count = 37 count = 38 count = 39 count = 40 count = 41 count = 42 count = 43 count = 44 count = 45 count = 46 count = 47 count = 48 count = 49 count = 50 count = 51

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

count = 1 count = 2 count = 3 count = 4 count = 5 count = 6 count = 7 count = 8 count = 9 count = 10 count = 11 count = 12 count = 13 count = 14 count = 15 count = 16 count = 17

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!