Cody

# Problem 6. Select every other element of a vector

Solution 3944103

Submitted on 1 Dec 2020 by Sam Wincott
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.0578 0.3977 0.1495 0.2942 0.3796

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.6463 0.4715 0.8278 0.7725 0.3616 0.6843 0.7425 0.6842 0.5633 0.2068 0.5626 0.7177 0.6417 0.3362 0.0706 0.0713 0.0555 Columns 18 through 34 0.6439 0.8656 0.7058 0.6710 0.3836 0.9477 0.3693 0.2311 0.7011 0.2759 0.2164 0.3226 0.9873 0.0896 0.7284 0.0273 0.0211 Columns 35 through 50 0.7335 0.9544 0.1644 0.4361 0.3281 0.1509 0.5805 0.0848 0.9192 0.0403 0.9837 0.8690 0.3900 0.3290 0.2594 0.5041

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!