Cody

# Problem 6. Select every other element of a vector

Solution 197732

Submitted on 28 Jan 2013 by Jalaj Bidwai
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))

idx = 1 0 1 0 1 0 1 0 1 0 y = 0.7262 0.1747 0.9935 0.7683 0.3184

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

idx = Columns 1 through 16 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 17 through 32 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 33 through 48 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 49 through 64 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 65 through 80 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 81 through 96 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 97 through 100 1 0 1 0 y = Columns 1 through 10 0.2992 0.6415 0.3852 0.6141 0.0107 0.1072 0.9581 0.1484 0.1279 0.9242 Columns 11 through 20 0.8635 0.6187 0.3035 0.2078 0.4558 0.1957 0.7758 0.0949 0.4629 0.7672 Columns 21 through 30 0.5731 0.4243 0.4835 0.2289 0.2546 0.4914 0.0428 0.5742 0.2674 0.4931 Columns 31 through 40 0.5572 0.1825 0.5232 0.6110 0.6159 0.6583 0.8846 0.1108 0.2847 0.5798 Columns 41 through 50 0.1850 0.7148 0.4889 0.8207 0.9392 0.3164 0.5969 0.9292 0.2944 0.7301

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

idx = Columns 1 through 16 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 Columns 17 through 31 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 y = Aogiegiaaayafrwy