Cody

# Problem 6. Select every other element of a vector

Solution 227529

Submitted on 6 Apr 2013 by kurguz
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.7859 0.6205 0.3035 0.5180 0.5507

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.2776 0.8654 0.8781 0.0943 0.0646 0.3455 0.0038 0.7256 0.8072 0.6742 Columns 11 through 20 0.6596 0.4604 0.7943 0.4024 0.8748 0.5694 0.9748 0.9743 0.1469 0.8093 Columns 21 through 30 0.5039 0.5264 0.5983 0.1148 0.2683 0.3806 0.1997 0.3455 0.2385 0.9351 Columns 31 through 40 0.0885 0.1488 0.5564 0.5363 0.5506 0.5245 0.3049 0.5795 0.5777 0.6054 Columns 41 through 50 0.9319 0.1963 0.6326 0.8719 0.6346 0.5525 0.4928 0.3388 0.0767 0.6867

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