Cody

# Problem 6. Select every other element of a vector

Solution 1213778

Submitted on 16 Jun 2017 by zefeng chen
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.4452 0.0557 0.6414 0.9395 0.9997

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.6087 0.3596 0.3878 0.0778 0.2181 0.3818 0.5769 0.6964 0.8625 0.4285 0.7542 0.8651 0.6036 0.1694 0.1389 0.9476 0.9211 Columns 18 through 34 0.1842 0.0571 0.9432 0.4715 0.1377 0.2651 0.2087 0.3200 0.4211 0.2200 0.1663 0.3050 0.6541 0.1251 0.6362 0.9049 0.1965 Columns 35 through 50 0.9471 0.9579 0.5690 0.9028 0.7028 0.3624 0.8135 0.3628 0.5555 0.0659 0.1678 0.9149 0.5992 0.7797 0.9223 0.3025

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!