Cody

# Problem 6. Select every other element of a vector

Solution 431855

Submitted on 14 Apr 2014 by Joel
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))

indices = [] indices = 0 1 0 1 0 1 0 1 0 y = 0.3922 0.1712 0.0318 0.0462 0.8235

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

indices = [] indices = Columns 1 through 16 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 17 through 32 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 33 through 48 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 49 through 64 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 65 through 80 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 81 through 96 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 97 through 99 0 1 0 y = Columns 1 through 9 0.3171 0.0344 0.3816 0.7952 0.4898 0.6463 0.7547 0.6797 0.1626 Columns 10 through 18 0.4984 0.3404 0.2238 0.2551 0.6991 0.9593 0.1386 0.2575 0.2543 Columns 19 through 27 0.2435 0.3500 0.2511 0.4733 0.8308 0.5497 0.2858 0.7537 0.5678 Columns 28 through 36 0.0540 0.7792 0.1299 0.4694 0.3371 0.7943 0.5285 0.6020 0.6541 Columns 37 through 45 0.7482 0.0838 0.9133 0.8258 0.9961 0.4427 0.9619 0.7749 0.8687 Columns 46 through 50 0.3998 0.8001 0.9106 0.2638 0.1361

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))

indices = [] indices = Columns 1 through 16 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Columns 17 through 31 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 y = Aogiegiaaayafrwy