Cody

# Problem 6. Select every other element of a vector

Solution 555546

Submitted on 11 Jan 2015 by John Nikas
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))

c = 0.2699 0.3711 0.0025 0.3821 0.3187

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

c = Columns 1 through 9 0.2646 0.9817 0.0415 0.1020 0.6955 0.4284 0.9464 0.5398 0.0448 Columns 10 through 18 0.1670 0.7690 0.2849 0.7672 0.2656 0.8769 0.5410 0.5715 0.5189 Columns 19 through 27 0.0883 0.6714 0.7699 0.8951 0.6054 0.9173 0.7700 0.9511 0.3862 Columns 28 through 36 0.3912 0.1960 0.7168 0.9011 0.8251 0.0183 0.4371 0.7591 0.3167 Columns 37 through 45 0.3309 0.9400 0.5663 0.2882 0.6053 0.7404 0.2478 0.1487 0.3427 Columns 46 through 50 0.5551 0.3602 0.3434 0.1612 0.6044

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

c = Aogiegiaaayafrwy