Cody

# Problem 6. Select every other element of a vector

Solution 222584

Submitted on 24 Mar 2013 by Bram Kuijvenhoven
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.5216 0.8181 0.7224 0.6596 0.9730

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

ans = Columns 1 through 9 0.8003 0.4324 0.0835 0.1734 0.8314 0.0605 0.5269 0.6569 0.2920 Columns 10 through 18 0.0155 0.1672 0.3724 0.4897 0.9516 0.0527 0.2691 0.5479 0.4177 Columns 19 through 27 0.3015 0.6663 0.6981 0.1781 0.9991 0.0326 0.8819 0.1904 0.4607 Columns 28 through 36 0.1564 0.6448 0.1909 0.4820 0.5895 0.3846 0.2518 0.6171 0.8244 Columns 37 through 45 0.7302 0.5841 0.9063 0.8178 0.5944 0.4253 0.1615 0.4229 0.5985 Columns 46 through 50 0.6959 0.6385 0.0688 0.5309 0.4076

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