Cody

# Problem 6. Select every other element of a vector

Solution 797520

Submitted on 23 Dec 2015 by Mei Tian
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.0166 0.0220 0.2518 0.0564 0.3953

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.9251 0.0174 0.9665 0.0917 0.0626 0.9692 0.6907 0.5091 0.3109 Columns 10 through 18 0.9060 0.2766 0.3671 0.4330 0.0014 0.5044 0.6737 0.3131 0.1348 Columns 19 through 27 0.5512 0.9645 0.2233 0.9313 0.7894 0.2706 0.1630 0.8596 0.3608 Columns 28 through 36 0.6558 0.6903 0.2723 0.5499 0.9972 0.3453 0.4113 0.9758 0.8470 Columns 37 through 45 0.0951 0.7779 0.4343 0.2093 0.2835 0.0546 0.7590 0.8991 0.6213 Columns 46 through 50 0.6343 0.6428 0.7948 0.1677 0.1851

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