Cody

# Problem 6. Select every other element of a vector

Solution 191940

Submitted on 16 Jan 2013 by Connor
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.5220 0.4409 0.2614 0.4597 0.1959

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.7416 0.1071 0.4549 0.9044 0.6038 0.0912 0.5476 0.2359 0.0790 0.1763 Columns 11 through 20 0.9703 0.3318 0.0249 0.9892 0.3969 0.5732 0.1455 0.5011 0.4064 0.8094 Columns 21 through 30 0.6741 0.1821 0.7699 0.4390 0.2168 0.5015 0.3644 0.1228 0.7366 0.1053 Columns 31 through 40 0.4237 0.0988 0.1536 0.1309 0.6631 0.7967 0.0669 0.9087 0.9898 0.9874 Columns 41 through 50 0.6521 0.7978 0.3772 0.0599 0.3834 0.9654 0.9556 0.3972 0.3619 0.4457

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