Cody

# Problem 6. Select every other element of a vector

Solution 1544238

Submitted on 30 May 2018 by Lewis Moran
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.2898 0.4068 0.8849 0.6098 0.9225

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

y = Columns 1 through 17 0.5622 0.9292 0.1945 0.0656 0.0890 0.4355 0.8818 0.6388 0.1367 0.3358 0.0799 0.5980 0.6481 0.7524 0.4699 0.1008 0.1991 Columns 18 through 34 0.7752 0.1936 0.0747 0.3733 0.5691 0.9760 0.3250 0.2221 0.5152 0.5470 0.2381 0.6231 0.6189 0.1517 0.7359 0.1426 0.9046 Columns 35 through 50 0.1082 0.8157 0.2101 0.0638 0.3778 0.8597 0.4987 0.9088 0.2348 0.7870 0.8380 0.5648 0.2491 0.8973 0.3268 0.4334

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!