Cody

# Problem 6. Select every other element of a vector

Solution 264863

Submitted on 20 Jun 2013 by Greg
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.7582 0.3859 0.2651 0.4348 0.2844

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.1240 0.6783 0.4612 0.6825 0.2240 0.0308 0.3041 0.8024 0.1172 0.7671 Columns 11 through 20 0.5179 0.7226 0.2083 0.9737 0.8201 0.6437 0.4678 0.7758 0.8096 0.3077 Columns 21 through 30 0.4919 0.1435 0.0622 0.2114 0.2259 0.7600 0.1994 0.0197 0.6106 0.8720 Columns 31 through 40 0.4163 0.2855 0.1387 0.2691 0.7812 0.9850 0.5831 0.2652 0.5074 0.8430 Columns 41 through 50 0.5095 0.3035 0.5581 0.6261 0.0063 0.6124 0.2419 0.0278 0.3290 0.7325

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