Cody

# Problem 6. Select every other element of a vector

Solution 204687

Submitted on 16 Feb 2013 by Marc Savoie
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.0252 0.7237 0.2615 0.2145 0.0330

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

y = Columns 1 through 10 0.3567 0.2644 0.1317 0.3044 0.6593 0.7721 0.9272 0.6875 0.8465 0.8424 Columns 11 through 20 0.7588 0.8744 0.5185 0.1795 0.0464 0.2327 0.5413 0.8571 0.1420 0.7775 Columns 21 through 30 0.0253 0.3632 0.8797 0.5452 0.0995 0.0342 0.1661 0.4155 0.6933 0.9123 Columns 31 through 40 0.2047 0.5872 0.6441 0.4500 0.7649 0.1431 0.8811 0.4779 0.7337 0.5335 Columns 41 through 50 0.3465 0.0211 0.8340 0.0331 0.0949 0.5222 0.1292 0.7218 0.1762 0.7150

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