Cody

# Problem 6. Select every other element of a vector

Solution 1141845

Submitted on 20 Mar 2017 by Dongdong Yue
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.9158 0.2336 0.9940 0.0386 0.1725

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.2727 0.8169 0.8198 0.8875 0.8180 0.8230 0.2659 0.5064 0.1897 0.0384 0.2997 0.8500 0.3001 0.9368 0.8584 0.6555 0.7317 Columns 18 through 34 0.6964 0.0062 0.3272 0.5487 0.0072 0.9613 0.6743 0.4420 0.0754 0.9837 0.9442 0.2531 0.0251 0.9194 0.4554 0.5004 0.6875 Columns 35 through 50 0.9197 0.6776 0.7798 0.1578 0.3613 0.2076 0.6947 0.2342 0.5144 0.6077 0.2844 0.5435 0.0602 0.4609 0.5544 0.7139

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!