Cody

# Problem 6. Select every other element of a vector

Solution 1583677

Submitted on 15 Jul 2018 by Ding Shengyuan
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.3646 0.7019 0.3963 0.4867 0.6780

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.1613 0.3800 0.9859 0.6870 0.6771 0.3161 0.6023 0.5770 0.5085 0.4803 0.8458 0.3235 0.3940 0.4765 0.7436 0.1914 0.3638 Columns 18 through 34 0.8519 0.0739 0.3187 0.3150 0.7359 0.5656 0.3565 0.1654 0.9463 0.2983 0.0133 0.1582 0.7630 0.1669 0.7540 0.7386 0.6880 Columns 35 through 50 0.4199 0.3039 0.4438 0.2112 0.6765 0.6937 0.3278 0.1972 0.5473 0.1783 0.1816 0.3845 0.9605 0.6751 0.1910 0.6135

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!