Cody

# Problem 6. Select every other element of a vector

Solution 57424

Submitted on 6 Mar 2012 by Sunu
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.4386 0.1891 0.2185 0.9256 0.7023

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

y = Columns 1 through 6 0.2573 0.5526 0.5577 0.0137 0.6590 0.7692 Columns 7 through 12 0.3877 0.1838 0.1941 0.9747 0.9481 0.1596 Columns 13 through 18 0.4402 0.7412 0.4575 0.0214 0.6260 0.5144 Columns 19 through 24 0.8771 0.2092 0.9262 0.7523 0.9481 0.5837 Columns 25 through 30 0.0100 0.8985 0.9316 0.1135 0.3347 0.5283 Columns 31 through 36 0.6453 0.1808 0.6641 0.9223 0.0797 0.9152 Columns 37 through 42 0.2361 0.6800 0.5769 0.4654 0.6328 0.5593 Columns 43 through 48 0.2615 0.9254 0.4462 0.0556 0.9858 0.4175 Columns 49 through 50 0.6612 0.5631

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