Cody

# Problem 6. Select every other element of a vector

Solution 236799

Submitted on 27 Apr 2013 by David Amor
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.6119 0.2949 0.3477 0.4025 0.5104

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.8934 0.9680 0.1839 0.6934 0.7078 0.8769 0.9205 0.2383 0.1337 0.2565 Columns 11 through 20 0.1330 0.2712 0.2030 0.8735 0.7943 0.3514 0.9214 0.2492 0.0736 0.7513 Columns 21 through 30 0.8262 0.0179 0.9244 0.8288 0.3068 0.0562 0.8833 0.5022 0.9888 0.9468 Columns 31 through 40 0.3196 0.8386 0.2332 0.5686 0.6706 0.6748 0.4141 0.3980 0.8118 0.9685 Columns 41 through 50 0.0157 0.8572 0.8162 0.0397 0.7305 0.7922 0.0598 0.1652 0.2699 0.8537

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