Cody

# Problem 6. Select every other element of a vector

Solution 127922

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

y = 0.5000 0.9047 0.6177 0.8055 0.1829

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

y = Columns 1 through 6 0.8865 0.4899 0.9787 0.5005 0.0596 0.0424 Columns 7 through 12 0.5216 0.8181 0.7224 0.6596 0.9730 0.8003 Columns 13 through 18 0.4324 0.0835 0.1734 0.8314 0.0605 0.5269 Columns 19 through 24 0.6569 0.2920 0.0155 0.1672 0.3724 0.4897 Columns 25 through 30 0.9516 0.0527 0.2691 0.5479 0.4177 0.3015 Columns 31 through 36 0.6663 0.6981 0.1781 0.9991 0.0326 0.8819 Columns 37 through 42 0.1904 0.4607 0.1564 0.6448 0.1909 0.4820 Columns 43 through 48 0.5895 0.3846 0.2518 0.6171 0.8244 0.7302 Columns 49 through 50 0.5841 0.9063

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