Cody

# Problem 6. Select every other element of a vector

Solution 823132

Submitted on 9 Feb 2016 by Martin C.
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.2933 0.9106 0.2456 0.9344 0.8054

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

y = Columns 1 through 9 0.6402 0.6746 0.5818 0.6834 0.2246 0.5595 0.5918 0.7036 0.7051 Columns 10 through 18 0.0744 0.8942 0.7067 0.1359 0.2623 0.8533 0.0565 0.0713 0.9500 Columns 19 through 27 0.0800 0.9270 0.3732 0.7092 0.0237 0.5571 0.0434 0.6506 0.6745 Columns 28 through 36 0.3277 0.5219 0.1433 0.0804 0.8702 0.8626 0.5566 0.3069 0.6561 Columns 37 through 45 0.5646 0.1973 0.5375 0.0739 0.7273 0.9745 0.3375 0.8294 0.6827 Columns 46 through 50 0.9793 0.6980 0.6355 0.1407 0.0587

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