Cody

# Problem 6. Select every other element of a vector

Solution 127927

Submitted on 15 Aug 2012 by Sadid
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.5949 0.6028 0.2217 0.2967 0.4242

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

ans = Columns 1 through 6 0.0855 0.8010 0.9289 0.4886 0.2373 0.9631 Columns 7 through 12 0.5211 0.4889 0.6791 0.3674 0.0377 0.9133 Columns 13 through 18 0.0987 0.3354 0.1366 0.1068 0.4942 0.7150 Columns 19 through 24 0.8909 0.6987 0.0305 0.5000 0.9047 0.6177 Columns 25 through 30 0.8055 0.1829 0.8865 0.4899 0.9787 0.5005 Columns 31 through 36 0.0596 0.0424 0.5216 0.8181 0.7224 0.6596 Columns 37 through 42 0.9730 0.8003 0.4324 0.0835 0.1734 0.8314 Columns 43 through 48 0.0605 0.5269 0.6569 0.2920 0.0155 0.1672 Columns 49 through 50 0.3724 0.4897

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