Cody

# Problem 6. Select every other element of a vector

Solution 1759986

Submitted on 24 Mar 2019 by caiwei liu
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.9335 0.2353 0.4880 0.8952 0.7634

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.4887 0.2678 0.1668 0.5005 0.9759 0.2177 0.6048 0.5559 0.8957 0.9726 0.1647 0.0081 0.8419 0.9004 0.8001 0.3858 0.8317 Columns 18 through 34 0.9544 0.2392 0.4987 0.2078 0.3332 0.8740 0.1835 0.3357 0.4900 0.9584 0.2311 0.0312 0.3317 0.9652 0.0486 0.3718 0.6959 Columns 35 through 50 0.1972 0.7051 0.4246 0.7320 0.4906 0.7905 0.8247 0.4830 0.5520 0.2754 0.1781 0.9671 0.1306 0.7473 0.2695 0.2598

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'