Cody

# Problem 6. Select every other element of a vector

Solution 607768

Submitted on 28 Mar 2015 by meepo iN
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.5436 0.3991 0.2351 0.4026 0.4577

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.2765 0.8073 0.9226 0.2519 0.3798 0.3048 0.3569 0.8849 0.4771 Columns 10 through 18 0.1598 0.5981 0.8890 0.9958 0.3788 0.7248 0.9876 0.3852 0.6642 Columns 19 through 27 0.3656 0.9030 0.2680 0.5829 0.7527 0.4366 0.3905 0.4149 0.8107 Columns 28 through 36 0.6364 0.8252 0.7222 0.3183 0.0452 0.5887 0.9187 0.2377 0.7951 Columns 37 through 45 0.2023 0.6166 0.3208 0.5290 0.7762 0.9476 0.1658 0.2644 0.2311 Columns 46 through 50 0.6841 0.0414 0.2340 0.2305 0.5310

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