Cody

# Problem 6. Select every other element of a vector

Solution 224085

Submitted on 27 Mar 2013 by David Mateos
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.1599 0.0537 0.1217 0.5931 0.4320

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.5079 0.6591 0.1472 0.5313 0.9005 0.0563 0.8893 0.6667 0.4469 Columns 10 through 18 0.8614 0.4788 0.9928 0.2198 0.6890 0.0090 0.2064 0.7091 0.4252 Columns 19 through 27 0.3224 0.2106 0.2083 0.2527 0.4818 0.3547 0.7498 0.6174 0.3025 Columns 28 through 36 0.8443 0.9088 0.6139 0.5081 0.0522 0.2187 0.6915 0.3596 0.3022 Columns 37 through 45 0.7961 0.7912 0.7395 0.9498 0.0196 0.9118 0.0713 0.0944 0.9155 Columns 46 through 50 0.0520 0.6912 0.8959 0.2320 0.8497

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