Cody

# Problem 6. Select every other element of a vector

Solution 484368

Submitted on 8 Aug 2014 by Klim Kolyvanov
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.5668 0.9985 0.8582 0.9933 0.6459 ans = []

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.2804 0.2859 0.4355 0.1007 0.5782 0.6719 0.1469 0.2364 0.2708 Columns 10 through 18 0.9794 0.3114 0.5082 0.2228 0.1173 0.9896 0.4286 0.6860 0.6844 Columns 19 through 27 0.8033 0.7982 0.3379 0.2959 0.4676 0.7930 0.7572 0.3926 0.2236 Columns 28 through 36 0.5611 0.6325 0.3052 0.4180 0.5476 0.4014 0.1510 0.9947 0.7110 Columns 37 through 45 0.4612 0.6875 0.1526 0.1652 0.4270 0.4128 0.7091 0.7258 0.7339 Columns 46 through 50 0.4558 0.3764 0.0125 0.4722 0.8797 ans = []

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 ans = []