Cody

# Problem 6. Select every other element of a vector

Solution 199907

Submitted on 3 Feb 2013 by davide
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))

ans = 0.0171 0.4384 0.2254 0.0145 0.7105

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

ans = Columns 1 through 10 0.2028 0.3970 0.7017 0.2113 0.8922 0.9843 0.7437 0.9978 0.4272 0.8519 Columns 11 through 20 0.2842 0.7741 0.4771 0.3917 0.3970 0.4285 0.6297 0.7774 0.0105 0.9933 Columns 21 through 30 0.6031 0.5133 0.9254 0.5382 0.9738 0.1851 0.0126 0.3496 0.7447 0.2558 Columns 31 through 40 0.1693 0.7461 0.4412 0.6099 0.0483 0.7691 0.9007 0.4830 0.2739 0.3113 Columns 41 through 50 0.9043 0.6106 0.9015 0.9745 0.5164 0.9963 0.9721 0.8128 0.9018 0.7486

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

ans = Aogiegiaaayafrwy