Cody

# Problem 6. Select every other element of a vector

Solution 2030675

Submitted on 21 Nov 2019 by Wei Wang
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.4075 0.1467 0.8746 0.5380 0.6800

2   Pass
x = rand(1,100); actual = everyOther(x); expected = x(1:2:length(x)); assert(isequal(actual, expected))

y = Columns 1 through 18 0.2588 0.4290 0.1282 0.8547 0.1751 0.9427 0.7777 0.3964 0.8836 0.5588 0.2767 0.0808 0.3641 0.9911 0.5376 0.5731 0.6884 0.5117 Columns 19 through 36 0.4925 0.5829 0.7609 0.9423 0.8108 0.7147 0.7304 0.7893 0.6352 0.6197 0.4012 0.2836 0.1692 0.3684 0.8463 0.9728 0.7175 0.0605 Columns 37 through 50 0.7964 0.7768 0.0068 0.5825 0.6500 0.9168 0.5474 0.7253 0.8243 0.8993 0.6698 0.1361 0.2956 0.7681

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!