Cody

# Problem 6. Select every other element of a vector

Solution 213727

Submitted on 6 Mar 2013 by Alex
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.3437 0.6114 0.5960 0.3873 0.6598

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.8859 0.4425 0.8553 0.3532 0.1848 0.1833 0.7810 0.0600 0.6619 0.7633 Columns 11 through 20 0.8977 0.0895 0.1384 0.9711 0.8069 0.6822 0.4967 0.7241 0.0796 0.5137 Columns 21 through 30 0.8144 0.9469 0.1802 0.5977 0.9275 0.2890 0.7667 0.4450 0.4210 0.0306 Columns 31 through 40 0.9080 0.8315 0.3056 0.6012 0.9118 0.7924 0.6510 0.2980 0.9224 0.1758 Columns 41 through 50 0.3253 0.2835 0.8913 0.8520 0.8755 0.9533 0.9238 0.6590 0.8196 0.3898

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