Cody

# Problem 6. Select every other element of a vector

Solution 252952

Submitted on 2 Jun 2013 by Milosz
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 = 0.2077 0.4709 0.8443 0.2259 0.2277

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

y = Columns 1 through 10 0.3111 0.4302 0.9049 0.4389 0.2581 0.5949 0.6028 0.2217 0.2967 0.4242 Columns 11 through 20 0.0855 0.8010 0.9289 0.4886 0.2373 0.9631 0.5211 0.4889 0.6791 0.3674 Columns 21 through 30 0.0377 0.9133 0.0987 0.3354 0.1366 0.1068 0.4942 0.7150 0.8909 0.6987 Columns 31 through 40 0.0305 0.5000 0.9047 0.6177 0.8055 0.1829 0.8865 0.4899 0.9787 0.5005 Columns 41 through 50 0.0596 0.0424 0.5216 0.8181 0.7224 0.6596 0.9730 0.8003 0.4324 0.0835

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