Cody

# Problem 6. Select every other element of a vector

Solution 224469

Submitted on 27 Mar 2013 by Michael
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.5581 0.6261 0.0063 0.6124 0.2419

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.0278 0.3290 0.7325 0.9935 0.7616 0.5906 0.3639 0.0306 0.2418 Columns 10 through 18 0.0219 0.0837 0.5942 0.3725 0.6954 0.5840 0.8467 0.3367 0.1435 Columns 19 through 27 0.4942 0.4762 0.2844 0.0590 0.9908 0.9979 0.5258 0.7263 0.6089 Columns 28 through 36 0.1579 0.3415 0.5184 0.1971 0.6502 0.8800 0.5018 0.1526 0.2423 Columns 37 through 45 0.8481 0.3917 0.1715 0.6260 0.6370 0.1351 0.2160 0.6674 0.0123 Columns 46 through 50 0.1581 0.8448 0.8144 0.5011 0.8801

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