Cody

# Problem 6. Select every other element of a vector

Solution 1078180

Submitted on 9 Dec 2016 by andreia3aral
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.9115 0.6760 0.3975 0.6571 0.2313

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.5328 0.3596 0.4392 0.1775 0.6692 0.9560 0.3903 0.4398 0.9205 Columns 10 through 18 0.7128 0.2960 0.1106 0.8209 0.6138 0.0993 0.4240 0.0264 0.5317 Columns 19 through 27 0.9878 0.4215 0.3988 0.9193 0.0850 0.1824 0.6183 0.7021 0.5112 Columns 28 through 36 0.3728 0.8914 0.6167 0.5990 0.8273 0.2080 0.5164 0.0938 0.9591 Columns 37 through 45 0.8780 0.6324 0.5123 0.6094 0.2384 0.9124 0.5868 0.5964 0.6315 Columns 46 through 50 0.6212 0.4694 0.0098 0.7566 0.6168

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!