Cody

# Problem 6. Select every other element of a vector

Solution 201294

Submitted on 6 Feb 2013 by Jeremy
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))

ans = 0.0900 0.1363 0.4952 0.4950 0.0550

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

ans = Columns 1 through 10 0.5606 0.6967 0.8154 0.9889 0.8654 0.9900 0.4795 0.2278 0.9009 0.8452 Columns 11 through 20 0.5860 0.6664 0.6260 0.7298 0.9823 0.5814 0.5801 0.1209 0.4843 0.2094 Columns 21 through 30 0.6299 0.6147 0.0495 0.1925 0.2055 0.1891 0.6352 0.5386 0.4991 0.4452 Columns 31 through 40 0.4904 0.8739 0.2085 0.6403 0.2060 0.0821 0.1420 0.6210 0.0521 0.7287 Columns 41 through 50 0.0634 0.9344 0.8589 0.5134 0.3986 0.0309 0.3013 0.3329 0.6482 0.8422

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

ans = Aogiegiaaayafrwy