Cody

# Problem 6. Select every other element of a vector

Solution 288415

Submitted on 24 Jul 2013 by Arief Anbiya
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.3947 0.7040 0.0196 0.4243 0.1971

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

y = Columns 1 through 10 0.4299 0.3912 0.3968 0.7551 0.2160 0.9493 0.6713 0.8335 0.1673 0.9899 Columns 11 through 20 0.8843 0.1548 0.4070 0.8256 0.3185 0.0900 0.1363 0.4952 0.4950 0.0550 Columns 21 through 30 0.5606 0.6967 0.8154 0.9889 0.8654 0.9900 0.4795 0.2278 0.9009 0.8452 Columns 31 through 40 0.5860 0.6664 0.6260 0.7298 0.9823 0.5814 0.5801 0.1209 0.4843 0.2094 Columns 41 through 50 0.6299 0.6147 0.0495 0.1925 0.2055 0.1891 0.6352 0.5386 0.4991 0.4452

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