Cody

# Problem 6. Select every other element of a vector

Solution 1903460

Submitted on 18 Aug 2019 by David Kuckuk
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.3454 0.6980 0.6473 0.3573 0.6039

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.5041 0.6587 0.6449 0.0745 0.8527 0.2627 0.2078 0.6493 0.2884 0.8385 0.8206 0.0968 0.6657 0.7501 0.9130 0.9767 0.3909 0.9657 Columns 19 through 36 0.3924 0.7440 0.6977 0.1607 0.4629 0.6754 0.1514 0.8947 0.4233 0.5784 0.4980 0.4132 0.0507 0.8787 0.2340 0.3460 0.6743 0.0772 Columns 37 through 50 0.9791 0.4570 0.8883 0.5846 0.6048 0.1547 0.4208 0.9351 0.9109 0.2700 0.3551 0.3403 0.5706 0.2572

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!