Cody

# Problem 6. Select every other element of a vector

Solution 699920

Submitted on 13 Jul 2015 by Brian
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.4735 0.5263 0.3587 0.6227 0.6980

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.8360 0.8262 0.8636 0.1468 0.0806 0.9769 0.8310 0.6655 0.7082 Columns 10 through 18 0.7974 0.5859 0.7670 0.4936 0.5230 0.9531 0.8087 0.1978 0.3499 Columns 19 through 27 0.3870 0.8619 0.6991 0.3080 0.5395 0.0015 0.8331 0.5615 0.2080 Columns 28 through 36 0.5432 0.8610 0.9401 0.9942 0.8468 0.0005 0.9160 0.8155 0.4322 Columns 37 through 45 0.5436 0.6546 0.1961 0.1331 0.7696 0.5723 0.1159 0.8960 0.0517 Columns 46 through 50 0.8058 0.5772 0.5532 0.9155 0.3132

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